Question

in the following Sunspot Rails scenario the has_and_belongs_to_many association does not get loaded despite of the include directive:

  has_and_belongs_to_many :predecessors, :join_table => 'next_phrases', :class_name => "Phrase", :foreign_key => 'next_id', :association_foreign_key => 'previous_id'


searchable :include =>[:predecessors] do
    integer :predecessor_ids, :multiple => true,:references => Phrase
end

are we doing anything wrong or is that a bug?

it does work if we call self.association(:predecessors).reload by hand

Was it helpful?

Solution

it might have something to do with the fact that predecessor_ids is an internal field of the type array. it works if the name is changed to integer :predecessors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top