You just need to use "IN" instead of "="
countries =
[''Germany'',''France'',''Spain'']
...
@users= User.find(:all,:conditions=>["country IN(?)", countries])
This will result in a statement like:
select * from users where country
in(''Germany'',''France'',''Spain'')
M
On Jul 8, 9:13 pm, cfingerh
<cfing...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I''m getting my records using:
>
> @users= User.find(:all,:conditions=>["country=? ",country])
>
> where country is a String with the name of the country.
>
> But now I want to get the result for different countries.
> I have an array
> countries =
[''Germany'',''France'',''Spain'']
>
> and I want to get all the records where country is one of those
> included in the array
>
> How can I do that?
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---