Module: SubjModels::CategoryModule

Defined in:
lib/subj_models/category.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(including_class) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/subj_models/category.rb', line 7

def self.included(including_class)

  including_class.class_eval do

    include SubjModels::ComprisingExternalId

    has_many :nomenclatures

    belongs_to :image, class_name: "DocumentFile"
    belongs_to :image_big, class_name: "DocumentFile"  

    validates :name, presence: true
    #validates :slug_url, length: { minimum: 4, maximum: 50 }, uniqueness: true, presence: true

    scope :by_slug_url, -> slug_url { where(slug_url: slug_url) }
    scope :is_public, -> condition { where(is_public: condition) }
    scope :by_id, -> ids { where(id: ids) }
    scope :exclude_by_id, -> ids { where.not(id: ids) }

  end

end

Instance Method Details

#to_sObject



30
31
32
# File 'lib/subj_models/category.rb', line 30

def to_s
  name
end