Class: Maglev::Asset
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Maglev::Asset
- Defined in:
- app/models/maglev/asset.rb
Class Method Summary collapse
-
.search(keyword, type, page = nil, per_page = nil) ⇒ Object
class methods ##.
Instance Method Summary collapse
-
#file ⇒ Object
validations ##.
-
#to_param ⇒ Object
methods ##.
Class Method Details
.search(keyword, type, page = nil, per_page = nil) ⇒ Object
class methods ##
18 19 20 21 22 23 24 25 26 |
# File 'app/models/maglev/asset.rb', line 18 def self.search(keyword, type, page = nil, per_page = nil) all .optimized .where(keyword.present? ? arel_table[:filename].matches("%#{keyword}%") : nil) .where(arel_table[:content_type].matches("%#{type}%")) .order(created_at: :desc) .page(page || 1) .per(per_page || 10) end |
Instance Method Details
#file ⇒ Object
validations ##
8 |
# File 'app/models/maglev/asset.rb', line 8 validates :file, presence: true |
#to_param ⇒ Object
methods ##
12 13 14 |
# File 'app/models/maglev/asset.rb', line 12 def to_param "#{id}-#{File.basename(filename, '.*').parameterize}#{File.extname(filename)}" end |