jquery - 思考狮身人面像多个类

标签 jquery ruby-on-rails search model thinking-sphinx

我有两个模型发布和评论,我想使用思考狮身人面像来搜索这两个模型,我在单个模型上工作得很好,但在搜索两个模型时出现错误“对象:类的未定义方法‘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/

相关文章:

javascript - 标题在应用 tablesorter 插件时搞砸了

jquery - 我们可以将 jquery.js 分成两部分吗?

ruby-on-rails - rails 走线问题

java - 当我在 SearchView 中输入内容时,列表的大小没有增加?

javascript - 单击时捕获链接 (<a>) 元素中的文本

jquery - css 的 Visited 属性不可用。我正在做一个便条盒,我需要你的建议

ruby-on-rails - ArgumentError : parent directory is world writable, FileUtils#remove_entry_secure 不起作用

ruby-on-rails - 将 Arel 作为别名应用于 Rails 的 ActiveRecord

php - 如何在 gettext 驱动的多语言站点上实现搜索?

python - 获取搜索词的行 - Notepad++ 的 Python 脚本