In my application i have the following models:

Item - has_and_belongs_to_many :orders
Order - has_and_belongs_to_many :items

This is a basic setup for a small shopping app, I can successfully
add/remove/edit a list of items to one or more orders, but now from the
administration i need to be able to perform a search like: "show orders
having (at least) item x and item y and item z (or more)"

Basically, i need to use AND conditions for items belonging to orders,
something like Order.find(:all, :conditions => "items.id = 2 AND
items.id = 5 AND ...", :include => [:items]) .
Obviously the query above doesn't work, but I can't figure out how to do
that.

Any suggestions?

Thanks in advance
-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to