0

How would I pass multiple options for the :without option in Sphinx with Rails? I have looked at http://freelancing-god.github.com/ts/en/searching.html but have not come up with anything.

User.search params[:search],
    :without => {:id => current_user.id && current_user.other_users.collect { 
      |other_user| other_user.id} # user cannot be self & user cannot already be a contact
    } # This is where I'm having the problem!

Help appreciated! I feel like the answer is simple and I'm just missing it... maybe I'm getting tired or something =/

dmonopoly
  • 3,251
  • 5
  • 34
  • 49

1 Answers1

1

There is an undocumented option called :without_any. It takes a hash whose key is the attribute to filter on and the value is an array of the values the attribute shouldn't match. In this case, I think you could do something like this:

contact_ids = current_user.other_users.collect(&:id)
User.search params[:search], :without_any => {:id => [current_user.id, contact_ids].flatten }
Adam
  • 3,148
  • 19
  • 20