Find item in loaded activerecords without making db call

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,

Do you mean something like this ?

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

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs