# Problems with find(:all, :conditions)

**URL:** <https://www.ruby-forum.com/t/problems-with-find-all-conditions/92345>\
**Category:** Rails\
**Created:** [April 18, 2007, 3:20pm UTC](https://www.ruby-forum.com/t/problems-with-find-all-conditions/92345 "2007-04-18T15:20:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cassiano\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ba9def/32.png) [@Cassiano\_R](https://www.ruby-forum.com/u/Cassiano_R)\
**Post date:** [April 18, 2007, 3:20pm UTC](https://www.ruby-forum.com/t/problems-with-find-all-conditions/92345/1 "2007-04-18T15:20:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Cassiano\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ba9def/32.png) [@Cassiano\_R](https://www.ruby-forum.com/u/Cassiano_R)\
**Post date:** [April 18, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/problems-with-find-all-conditions/92345/2 "2007-04-18T15:48:19Z")

</div>

On Apr 18, 2007, at 9:19 AM, Cassiano R. wrote:

> 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 B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
