Hi, e.g. I have two models: class Currency < ActiveRecord::Base .. end class ProductPrice < ActiveRecord::Base belongs_to :currency .. end currencies table has 2 records: id name 1 USD 2 EUR when I run: prices = ProductPrice.find(:al) I get array of ProductPrice instances where each object has currency attr. RoR makes the query ''select * from currencies where id=NNN'' for each instance. So I have scores of equal queries. Is an ability to avoid permanent "get" from db ? Can RoR cache all records from currencies (any given) table and then use them? Sure, I can store all curencies table''s records to array and manually use them (without build-in RoR relationships) but I think I lose some RoR advantages. prices = ProductPrice.find(:all, :include => [:currency]) not works in Oracle Thanks. -- 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 -~----------~----~----~----~------~----~------~--~---
vlad wrote:> Hi, > e.g. I have two models: > class Currency < ActiveRecord::Base > .. > end > > class ProductPrice < ActiveRecord::Base > belongs_to :currency > .. > end > > currencies table has 2 records: > id name > 1 USD > 2 EUR > > when I run: > prices = ProductPrice.find(:al) > I get array of ProductPrice instances where each object has currency > attr. RoR makes the query ''select * from currencies where id=NNN'' for > each instance. So I have scores of equal queries. > > Is an ability to avoid permanent "get" from db ? Can RoR cache all > records from currencies (any given) table and then use them? > > Sure, I can store all curencies table''s records to array and manually > use them (without build-in RoR relationships) but I think I lose some > RoR advantages.I''d recommend using the acts_as_enumerated plugin: http://wiki.rubyonrails.org/rails/pages/Acts+As+Enumerated+Plugin -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks -- 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 -~----------~----~----~----~------~----~------~--~---