Problem with has_many based search

15 views
Skip to first unread message

beagile

unread,
Mar 28, 2012, 11:48:51 AM3/28/12
to thinkin...@googlegroups.com
Hi!

I have the following model:

class User < ActiveRecord::Base
  has_many :user_speaks_languages, :dependent   => :destroy

  define_index do
    indexes username
    has user_speaks_languages(:id), :as => :user_speaks_languages   
  end
end

When I search with the following command:
User.search(:with => {:user_learns_languages=>"1819"}, :per_page => 1000)
[1408]

I only get one user back, but I would expect to get several users back who all speak this language.
Why is that?

My real user-model has more relations and more fields and attributes... and I can search on them just fine. 
But this index attribute seems not to work for me...

Would be very happy if someone could help!

Govinda



beagile

unread,
Mar 30, 2012, 4:08:18 AM3/30/12
to Thinking Sphinx
My fault. Thinking Sphinx worked correctly. I just indexed (and
searched) not the right column of the associated model.

Govinda
Reply all
Reply to author
Forward
0 new messages