# ActiveRecord types of find

**URL:** <https://www.ruby-forum.com/t/activerecord-types-of-find/145343>\
**Category:** Rails\
**Created:** [August 8, 2008, 8:29am UTC](https://www.ruby-forum.com/t/activerecord-types-of-find/145343 "2008-08-08T08:29:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [August 8, 2008, 8:29am UTC](https://www.ruby-forum.com/t/activerecord-types-of-find/145343/1 "2008-08-08T08:29:59Z")

</div>

Hi,  
If I do the following ActiveRecord query  
AccountType.find\_by\_active(true).collect{|at| [at.name,at.id]}  
I get the error  
undefined method `collect’ for #AccountType:0x459fb10

However if I do  
AccountType.find(:all,:conditions=\>["active= ? ", true]).collect{|at|  
[at.name,at.id]}

then everything is fine.

Why does the find\_by\_active(true) method work differently from the  
longhand version?

Cheers  
George

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [August 8, 2008, 9:51am UTC](https://www.ruby-forum.com/t/activerecord-types-of-find/145343/2 "2008-08-08T09:51:55Z")

</div>

Hi,

find\_by\_something returns first record matched by default.

What you are loking for is find\_all\_by\_something that returns an  
array.

Best,  
H.

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [August 8, 2008, 11:23am UTC](https://www.ruby-forum.com/t/activerecord-types-of-find/145343/3 "2008-08-08T11:23:22Z")

</div>

Thanks for that.

That makes sense

Cheers  
George
