Eager loading in the Model versus in find


#1

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.