Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FinalAsset < Asset
- include PgSearch
- self.table_name = 'final_assets'
- belongs_to :project_deliverable, foreign_key: :deliverable_id
- pg_search_scope :search, against: [:title,
- :client_code_name,
- :client_code_abbreviation,
- :user_first_name,
- :user_last_name,
- :project_name,
- :mat_id],
- using: {
- tsearch: {prefix: true}
- }
- class << self
- def sort_by_newest
- order(created_at: :desc)
- end
- def sort_by_oldest
- order(created_at: :asc)
- end
- def filter_by_client_code_ids(client_code_ids)
- where(client_code_id: client_code_ids)
- end
- def filter_by_asset_types(asset_types)
- # asset_types = {'BroadcastDeliverable' => 0, 'VideoDeliverable' => 4}
- # iterate over key, value pairs and chain scopes
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement