# Eager loading in the Model versus in find

**URL:** <https://www.ruby-forum.com/t/eager-loading-in-the-model-versus-in-find/158465>\
**Category:** Rails\
**Created:** [January 23, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/eager-loading-in-the-model-versus-in-find/158465 "2009-01-23T17:02:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinhboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f07891/32.png) [@vinhboy](https://www.ruby-forum.com/u/vinhboy)\
**Post date:** [January 23, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/eager-loading-in-the-model-versus-in-find/158465/1 "2009-01-23T17:02:40Z")

</div>

Hi,

Can you someone help me understand this.

When I am eager loading something in the Model, like this:

* * *

Class Customer \< ActiveRecord::Base

has\_many :orders, :include =\> :line\_items

## end

( assume orders and line\_items belongs\_to customer, and order has\_many  
line\_items )  
versus in the controller like this:

@customers = Customer.find(:all, :include =\> [:orders =\> :line\_items])

I get different results.  
Declaring the eager loading in the Model does not work.  
But when I do it through the find, it works, I can see the data being  
fetched in the SQL and I can see it in the instance variable.

Thank You.
