Patrick wrote:> All products have an order_id, but some orders are open and some are
> closed. I need a way to find all products that belong to open orders
> (the field status = 1 in the orders table).
>
> Here''s the general idea of what I''m trying to do:
>
> @products = Product.find(:all, :conditions=>["order.status =
?", "1"])
>
> order.status obviously isn''t working because it''s a
reference to a
> different table. I''m having a hard time figuring out how to get
this to
> do what I need it to do.
>
> Thanks!!
Add a joins clause to your find, eg :joins => ''INNER JOIN orders on
etc..."
Fred
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---