Files
old-holivud2/app/models/file_info.rb
2020-05-31 22:38:19 +02:00

13 lines
443 B
Ruby

class FileInfo < ApplicationRecord
belongs_to :releasable, polymorphic: true
scope :audio, -> { where("content_type ILIKE ?", "%audio%") }
scope :video, -> { where("content_type ILIKE ?", "%video%") }
scope :photo, -> { where("content_type ILIKE ?", "%image%") }
scope :other, -> { where("NOT content_type ILIKE ?", "%(image|video|audio)%") }
def self.search_filename(query)
where("filename ILIKE ?", "%#{query}%")
end
end