ruby-on-rails - 思考狮身人面像,联想不起作用

标签 ruby-on-rails ruby thinking-sphinx

我有一个模型:

class Topic < ActiveRecord::Base

  define_index do 
    indexes title, :sortable => true
    indexes body
    indexes tags(:name), :as => :tag_name
  end

  has_and_belongs_to_many :tags, :join_table => 'topic_tags', :order => 'tags.name asc'

end

当我运行时:

rake ts:rebuild

I get:

sql_range_query: Unknown column 'topics.name' in 'field list'

And my 'config/development.sphinx.conf' has this oddness:

  sql_query = SELECT `topics`.`id` * 1 + 0 AS `id` , CAST(`topics`.`title` AS CHAR) AS 
`title`, CAST(`topics`.`body` AS CHAR) AS `body`, CAST(`topics`.`name` AS CHAR) AS 
`tag_name`, `topics`.`id` AS `sphinx_internal_id`, 1552019743 AS `class_crc`, '1552019743'
 AS `subclass_crcs`, 0 AS `sphinx_deleted`, IFNULL(`topics`.`title`, '') AS `title_sort` 
FROM `topics`    WHERE `topics`.`id` >= $start AND `topics`.`id` <= $end GROUP BY 
`topics`.`id`  ORDER BY NULL
  sql_query_range = SELECT IFNULL(MIN(`id`), 1), IFNULL(MAX(`id`), 1) FROM `topics`

因此,出于某种原因,协会看起来破灭了,我哪里做错了,我该如何解决这个问题?

(运行rails 2.3.4和最新thinking sphinx 1.2.11)

最佳答案

琐碎的陷阱:

这个有效:

class Topic < ActiveRecord::Base
  has_and_belongs_to_many :tags, :join_table => 'topic_tags', :order => 'tags.name asc'

  define_index do 
    indexes title, :sortable => true
    indexes body
    indexes tags(:name), :as => :tag_name
  end



end

关联必须在索引之前定义。

关于ruby-on-rails - 思考狮身人面像,联想不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1457724/

相关文章:

javascript - 如何在服务器处理 RoR/JQuery 中的请求时禁用按钮

ruby-on-rails - 检查 https 状态码 ruby

ruby-on-rails - 执行验证和保存的顺序

ruby-on-rails - Rails 4.1 强制 ActionMailer 返回其他值

mysql - 开发中连接 Sphinx MySQL 时遇到问题

ruby-on-rails - 如何在 Thinking Sphinx 中一起使用多值属性 (MVA) 和方面?

ruby-on-rails - Netbeans 和 Rails 错误 : bin/ruby: No such file or directory -- script/rails (LoadError)

ruby-on-rails - 在 lhm(大型强子迁移器)中添加默认列

ruby-on-rails - 如何在 Rails 中添加返回 "variables"的方法?

mysql - 如何配置 PostgreSQL 或 MySQL 以使用 Sphinx 设置数据库?