Hi There,
I am just beginning to learn Ruby on Rails, and I haven't been able to find the answer to this question.
I have the following code:
@products = Product.find(:all,
:conditions => ["productsubtype_id = ?", @productsubtypes],
:order => "name")
@productsubtypes is an array (currently containing two objects from another SQL query, almost identical to this one) - the SQL it generates is the following:
SELECT * FROM `products` WHERE (productsubtype_id = 2,3) ORDER BY name
As you can see, the above is not valid (at least, not for MySQL) - I need to find a way to change the original Ruby code to generate the following SQL code (or something close to it:
SELECT * FROM `products` WHERE (productsubtype_id = 2
OR productsubtype_id = 3) ORDER BY name
Is there a way to change the original code to do what I need, or am I on completely the wrong track here?
Thanks for your help,
Juan