太阳黑子搜索包括不加载has_and_belongs_to_many关联

时间:2013-02-20 16:07:25

标签: ruby-on-rails-3 sunspot sunspot-rails

在以下Sunspot Rails场景中,尽管有include伪指令,但has_and_belongs_to_many关联仍未加载:

  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

我们做错了什么或是一个错误?

如果我们手动调用self.association(:predecessors).reload

,它确实有效

1 个答案:

答案 0 :(得分:0)

它可能与predecessor_ids是类型数组的内部字段这一事实有关。如果名称更改为integer:predecessors。