Associations issue with Thinking Sphinx plugin for Rails
I have many sphinx_scopes in my application's models, but one of them doesn't work, I think it's because the odd way Sphinx store the associated values.
As an example I will show some key pieces of my Product class model, 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 }
} }
Then I try开发者_开发技巧 in console:
Product.by_state('whatever_i_put_here_throws_same_resultset')
I guess sphinx is not storing the string properly, any ideas? Thanks a lot!
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
You defined your scope as :by_state
but you're trying to call Product.by_city
. Is there another scope defined that we're not seeing here?
精彩评论