Module: EnjuSubject::EnjuManifestation::ClassMethods

Defined in:
lib/enju_subject/manifestation.rb

Instance Method Summary collapse

Instance Method Details

#enju_subject_manifestation_modelObject



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

def enju_subject_manifestation_model
  include InstanceMethods
  attr_accessible :subjects_attributes, :classifications_attributes
  has_many :subjects
  has_many :classifications
  accepts_nested_attributes_for :subjects, :allow_destroy => true, :reject_if => :all_blank
  accepts_nested_attributes_for :classifications, :allow_destroy => true, :reject_if => :all_blank

  searchable do
    text :subject do
      subjects.map{|s| [s.term, s.term_transcription]}.flatten.compact
    end
    string :subject, :multiple => true do
      subjects.map{|s| [s.term, s.term_transcription]}.flatten.compact
    end
    string :classification, :multiple => true do
      classifications.collect(&:category)
    end
    integer :subject_ids, :multiple => true
  end
end