Depth needed in model()


#1

If there are models of type M in session, and objects of type M
contain objects of type M’, does M’ need to be included in model()?

– fxn


#2

Xavier N. wrote:

If there are models of type M in session, and objects of type M contain
objects of type M’, does M’ need to be included in model()?
If by “contain” you mean has_many, then I think not… the has_many
method calls require_association_class which does the necessary.


#3

On Mar 5, 2006, at 23:22, Alex Y. wrote:

Xavier N. wrote:

If there are models of type M in session, and objects of type M
contain objects of type M’, does M’ need to be included in model()?
If by “contain” you mean has_many, then I think not… the
has_many method calls require_association_class which does the
necessary.

I meant “references”, either directly or indirectly by means of some
standard class like “Array of non-AR models”.

Looks like a good rule of thumb would be: if all child models are
referenced by means of AR’s DSL like has_many, has_one, etc. then
only the root model needs to be passed to model(). Otherwise pass as
many models as needed recursively (sounds very fragile). In any case,
putting a model that would be loaded anyway does not hurt.

Does that look right?

– fxn