Eager

Hi

i’m trying to have an eager loading on 4 tables.
those tables are :
products, store_entries, stores, store_shipping_countries.
and i don’t know how to load “store_shipping_countries” in the include
parameter when i do a Product.find

how can i do it?

Jean-sébastien Jney wrote:

Hi

i’m trying to have an eager loading on 4 tables.
those tables are :
products, store_entries, stores, store_shipping_countries.
and i don’t know how to load “store_shipping_countries” in the include
parameter when i do a Product.find

how can i do it?

prior to rails 2.0 you can use

class SomeConroller
model :products
end

don’t know how it 2.0 yet though srry

i already do a “:through” to access store from product.
so i tried in product :
has_many :store_shipping_countries, :through => :stores
but it doesn’t work.
if none can help, i think i will use find_by_sql instead of the
regular find

On May 17, 5:46 am, Keynan P. [email protected]

Hi,

i already do a “:through” to access store from product.
so i tried in product :
has_many :store_shipping_countries, :through => :stores
but it doesn’t work.

Assuming you have a relationship called “stores” from product and
another called “store_shipping_countries” from stores, then this should
work fine.

Product.find(:all,:include=>{:stores=>:store_shipping_countries})

Regards,

javier ramirez