Sha256: 706c7ecae068d953678336d05b7aa8d6ec6249d987c81ce8019256502b408c58
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
require 'subj_models/concerns/comprising_external_id' require 'subj_models/concerns/shared_scopes' module SubjModels module BrandLine 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, nomenclatures: :specialist_activity).where('brands.id' => brand_ids_string.split(',')) end end end end def to_s name end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
subj_models-0.4.1 | lib/subj_models/brand_line.rb |
subj_models-0.4 | lib/subj_models/brand_line.rb |