# Eager

**URL:** <https://www.ruby-forum.com/t/eager/104359>\
**Category:** Rails\
**Created:** [May 17, 2007, 5:11am UTC](https://www.ruby-forum.com/t/eager/104359 "2007-05-17T05:11:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [May 17, 2007, 5:11am UTC](https://www.ruby-forum.com/t/eager/104359/1 "2007-05-17T05:11:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [May 17, 2007, 5:46am UTC](https://www.ruby-forum.com/t/eager/104359/2 "2007-05-17T05:46:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [May 17, 2007, 8:21am UTC](https://www.ruby-forum.com/t/eager/104359/3 "2007-05-17T08:21:01Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [May 17, 2007, 10:44am UTC](https://www.ruby-forum.com/t/eager/104359/4 "2007-05-17T10:44:13Z")

</div>

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
