Hi,
I have a collection of Vehicles which belongs_to a number of entities such as Manufacturer, Transmission and Fuel. When rendering individual Vehicles in the collection, I access vehicle.manufacturer.name and vehicle.transmission.name. Each time I access these properties, some SQL is equcuted such as:
'SELECT * FROM manufacturers WHERE (manufacturers.id = 1) LIMIT 1'
As this data is virtually static, is there a way to cache this data and still use the association vehicle.manufacturer.name?
You can instruct AR to retrieve manufacturer and transmission data in the same SELECT statement as the vehicles:
Vehicle.find(:all, :include=>[:manufacturer, :transmission])
Cheers, Max