# Find item in loaded activerecords without making db call

**URL:** <https://www.ruby-forum.com/t/find-item-in-loaded-activerecords-without-making-db-call/132552>\
**Category:** Rails\
**Created:** [March 21, 2008, 10:52am UTC](https://www.ruby-forum.com/t/find-item-in-loaded-activerecords-without-making-db-call/132552 "2008-03-21T10:52:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![betame342](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/90db22/32.png) [@betame342](https://www.ruby-forum.com/u/betame342)\
**Post date:** [March 21, 2008, 10:52am UTC](https://www.ruby-forum.com/t/find-item-in-loaded-activerecords-without-making-db-call/132552/1 "2008-03-21T10:52:01Z")

</div>

Hi,

Does anyone know how to filtered/find item in loaded activerecords  
without making another call to database again? For example, I stored all  
domains in class variable as activerecords. Now, I want to filtered/find  
that domains in this domains class variable. How to do that? I try  
with\_scope but it make another call to database. The key question is  
filtered.find item in loaded active records without making another db  
call. Also, the output of the result need to be activerecords. So I can  
use helpers method associated with it.

Thank you in advance,

---

<div class="post-metadata">

**Author:** ![betame342](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/90db22/32.png) [@betame342](https://www.ruby-forum.com/u/betame342)\
**Post date:** [March 21, 2008, 10:56am UTC](https://www.ruby-forum.com/t/find-item-in-loaded-activerecords-without-making-db-call/132552/2 "2008-03-21T10:56:46Z")

</div>

Do you mean something like this ?

@loaded = Item.find(:all)  
@filtered = @loaded.select{|item| item.name == “search”}

---

<div class="post-metadata">

**Author:** ![betame342](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/90db22/32.png) [@betame342](https://www.ruby-forum.com/u/betame342)\
**Post date:** [March 21, 2008, 12:16pm UTC](https://www.ruby-forum.com/t/find-item-in-loaded-activerecords-without-making-db-call/132552/3 "2008-03-21T12:16:39Z")

</div>

Stijn P. wrote:

> Do you mean something like this ?
> 
> @loaded = Item.find(:all)  
> @filtered = @loaded.select{|item| item.name == “search”}

thank you very much, it solve my problem.
