# Searching activerecord result arrays "include?" does not work

**URL:** <https://www.ruby-forum.com/t/searching-activerecord-result-arrays-include-does-not-work/187515>\
**Category:** Rails\
**Created:** [April 24, 2010, 3:25pm UTC](https://www.ruby-forum.com/t/searching-activerecord-result-arrays-include-does-not-work/187515 "2010-04-24T15:25:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MJFuzz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/48db29/32.png) [@MJFuzz](https://www.ruby-forum.com/u/MJFuzz)\
**Post date:** [April 24, 2010, 3:25pm UTC](https://www.ruby-forum.com/t/searching-activerecord-result-arrays-include-does-not-work/187515/1 "2010-04-24T15:25:12Z")

</div>

I’m racking my brain with this and I know there’s an easy way to do  
this.

I have a Model.find result array. I need to check to see if a value  
exists in that array result. Array.include? always returns false I  
assume cause its an array of objects. So how do I search the resulting  
array??

---

<div class="post-metadata">

**Author:** ![MJFuzz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/48db29/32.png) [@MJFuzz](https://www.ruby-forum.com/u/MJFuzz)\
**Post date:** [April 24, 2010, 3:29pm UTC](https://www.ruby-forum.com/t/searching-activerecord-result-arrays-include-does-not-work/187515/2 "2010-04-24T15:29:53Z")

</div>

Never mind… I was searching on the value and not checking if the  
class exists in the array… duh…

---

<div class="post-metadata">

**Author:** ![MJFuzz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/48db29/32.png) [@MJFuzz](https://www.ruby-forum.com/u/MJFuzz)\
**Post date:** [April 24, 2010, 3:32pm UTC](https://www.ruby-forum.com/t/searching-activerecord-result-arrays-include-does-not-work/187515/3 "2010-04-24T15:32:50Z")

</div>

MJFuzz wrote:

> I’m racking my brain with this and I know there’s an easy way to do  
> this.
> 
> I have a Model.find result array. I need to check to see if a value  
> exists in that array result. Array.include? always returns false I  
> assume cause its an array of objects. So how do I search the resulting  
> array??

Why do you need to? Normally you should let the DB do things like this.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
