Sha256: a5c68e1f6603f7413b556a888c540f30ab5b3ad84973d6b43681607c55b99004
Contents?: true
Size: 1.31 KB
Versions: 8
Compression:
Stored size: 1.31 KB
Contents
module EnjuSubject module EnjuManifestation def self.included(base) base.extend ClassMethods end module ClassMethods def enju_subject_manifestation_model include InstanceMethods 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 after_save do subject_index! end after_destroy do subject_index! end 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.map{|c| "#{c.classification_type.name}_#{c.category}"} end integer :subject_ids, :multiple => true end end module InstanceMethods def subject_index! subjects.map{|subject| subject.index} classifications.map{|classification| classification.index} Sunspot.commit end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems