ActiveRecord eager loading of associations

Hi, All.

I have following model.

Category has_many_and_belongs to Property. Property belongs_to Term.

In controller i receive category_id from user. I need to load for this
category all properties that belongs to Category with it’s term.

For now I have following code

@props = Category.find(@params[:selected_category]).properties

and in view
for each p in @props
<%p.term.name%>

but as I understand term not loaded in Category.find so <%p.term.name%>
throws “nil have no name method”. (p.term is nil)

So my question is simple how to load term during find.

Thanks for any response.


anatol

Is it really no way to switch on eager loading for sccotioations??

I could not beleive that ActiveRecord have no solutions for it…

On 11/8/05, Anatol P. [email protected] wrote:

For now I have following code
So my question is simple how to load term during find.

Thanks for any response.


anatol


anatol