Sha256: 1d29179fd78638845664e764caac7f26dad304fc31078ac59d9982da23cfd28e
Contents?: true
Size: 1.07 KB
Versions: 18
Compression:
Stored size: 1.07 KB
Contents
module EnjuSubject module EnjuManifestation extend ActiveSupport::Concern included do 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 def subject_index! subjects.map{|subject| subject.index} classifications.map{|classification| classification.index} Sunspot.commit end end end
Version data entries
18 entries across 18 versions & 1 rubygems