Sha256: 306e4ef91119860c91e3aff8d917d7744fa4748bec479aa7bce482414edf0bd0
Contents?: true
Size: 1.15 KB
Versions: 49
Compression:
Stored size: 1.15 KB
Contents
require 'subj_models/concerns/comprising_external_id' require 'subj_models/concerns/shared_scopes' module SubjModels module BrandLineModule def self.included(including_class) including_class.class_eval do include SubjModels::SharedScopes include SubjModels::ComprisingExternalId belongs_to :brand belongs_to :document_file has_many :nomenclatures validates :name, presence: true scope :brand_id, -> (brand) do return all unless brand.present? parent_id_scope("brand", brand) end scope :to_show, -> () { where(show_on_index: true) } scope :is_recommended, -> (condition) { where(is_recommended: condition) } scope :category_id, -> (category) do return all unless category.present? joins(:brand, nomenclatures: :category).where('categories.id' => category) end scope :brand_ids, -> (brand_ids_string) do unless brand_ids_string.blank? joins(:brand).where('brands.id' => brand_ids_string.split(',')) end end end end def to_s name end end end
Version data entries
49 entries across 49 versions & 2 rubygems