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, -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Stijn Pint
2008-Mar-21 09:56 UTC
Re: Find item in loaded activerecords without making db call
Do you mean something like this ? @loaded = Item.find(:all) @filtered = @loaded.select{|item| item.name == "search"} -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Beta Beta
2008-Mar-21 11:16 UTC
Re: Find item in loaded activerecords without making db call
Stijn Pint 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---