On Apr 18, 2007, at 9:19 AM, Cassiano Roloff wrote:> I need find all people with "type" in 2,3,4,5...
> so I wrote this find:
>
> Person.find(:all, :conditions => [''type in (?)'',
"#{params[:types]}"]
>
> and the params[:types] is an Array.
>
> ActiveRecord generate this SQL:
>
> select .... where type in ("12345")
>
> But, I need this SQL instruction:
>
> select .... where type in ("1", "2", "3",
"4", "5" )
>
> What is wrong?
>
> thanks for your help.
Person.find(:all, :conditions => [''type in (?)'',
params[:types]])
If params[:types] is an Array, then don''t force it to be a string by
interpolating it yourself with "#{}".
-Rob
Rob Biedenharn http://agileconsultingllc.com
Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---