我有两个模型发布和评论,我想使用思考狮身人面像来搜索这两个模型,我在单个模型上工作得很好,但在搜索两个模型时出现错误“对象:类的未定义方法‘sphinx_index_options’”。
我遇到的错误 错误“对象:类的未定义方法‘sphinx_index_options’”
在帖子中模型是
define_index do
indexes [topic, body], as: :post
has cached_tag_list, :as => :tag_ids
indexes comments.body, :as => :comment
has created_at
where "is_private='f'"
end
has_many :comments, :as=>:commentable, :order => "created_at asc", :dependent =>:destroy
和评论模型
define_index do
indexes [body, other], as: :comment
has created_at
end
belongs_to :commentable, :polymorphic => true
在我的 Controller 中查询是
if params[:query]
@query = params[:query]
page = params[:page] || 1
@search = ThinkingSphinx.search @query, :classes=>[Post, Comment], :order=>:created_at, :sort_mode=>:desc, :field_weights=>{:topic=>2.0}, :per_page=>15, :page=>page
@total_entries = @search.total_entries 别的 渲染: Action =>:搜索表单, 结束
最佳答案
这是因为单表继承。更新你的思维 sphinx gem ~> 2.0.12.
关于jquery - 思考狮身人面像多个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9479985/