0

我的应用程序模型中有很多sphinx_scopes,但其中一个不起作用,我认为这是因为 Sphinx 存储关联值的奇怪方式。

作为示例,我将展示我的 Product 类模型 product.rb 的一些关键部分:

...
belongs_to :partner
# And partner belongs to city
...
define_index do
   ...
   has partner.city(:state_name), :as => :state, :type => :string
   #has partner.city.state_name, :as => :state, :type => :string
   ...
end
...
sphinx_scope(:by_state) { | name | {
   :with => { :state => name }
 } }

然后我在控制台中尝试:

Product.by_state('whatever_i_put_here_throws_same_resultset')

我猜狮身人面像没有正确存储字符串,有什么想法吗?非常感谢!

4

2 回答 2

2

Asked the authors: http://groups.google.com/group/thinking-sphinx/browse_thread/thread/22fe3c7aa6ef4567

Found the problem here: http://freelancing-god.github.com/ts/en/common_issues.html#string_filters

于 2010-07-31T21:44:09.977 回答
0

您将范围定义为,:by_state但您试图调用Product.by_city. 是否定义了另一个我们在这里没有看到的范围?

于 2010-07-31T05:48:17.390 回答