我的应用程序模型中有很多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')
我猜狮身人面像没有正确存储字符串,有什么想法吗?非常感谢!