AR caching for belongs_to

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.

vlad wrote:

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.

Thanks