Module: SubjModels::ContentBlockModule

Defined in:
lib/subj_models/content_block.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
# File 'lib/subj_models/content_block.rb', line 7

def self.included(including_class)

  including_class.class_eval do

    include SubjModels::ComprisingExternalId

    belongs_to :document_file
    has_one :brand

  end

end

Instance Method Details

#to_sObject



20
21
22
23
24
# File 'lib/subj_models/content_block.rb', line 20

def to_s
  brands = Brand.where('content_block1_id=? OR (content_block2_id=? OR content_block3_id=?)', id, id, id)
  addition_text = brands.any? ? "#{brands.first.try(:name)}" : 'Без бренда'
  "#{title} - " + addition_text
end