I'm starting off with something that already works, and trying to add
another condition to it. I just can't seem to find an example of the
proper syntax to make this happen.
In this case, I have users, and users have many contacts and contacts
have and belong to many groups. Up til now I've just been searching for
(and paginating) a set of contacts that belong to this user that are
"LIKE" my search term. Now I want to also limit the selection by which
groups a contact belongs to.
So far I've been finding a set of contacts to show like this:
@contacts = @current_user.contacts.paginate(:all, :conditions => ["name
LIKE ?", search_term])
Now I want to add to that, a selection based on a group, so, in pseudo
syntax that might look something like this:
@contacts = @current_user.contacts.paginate(
:all,
:conditions => ["name LIKE ?",
search_term],
:joins => :group,
:more_conditions => {:groups =>
{:group.id => selected_group}})
How do I hook these two different types of conditions together?
Thanks!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---