You can actually call the preload_associations method whenever you
want. It's not public, though, so you need to use send() -- perhaps
that should change?

On Aug 20, 6:08 pm, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On Aug 18, 10:40 pm, cainlevy <[EMAIL PROTECTED]> wrote:
>
>
>
> > I like the preloading functionality in ActiveRecord. Can we expose an
> > API option for it? I know it's important to be careful with adding AR
> > options, but I believe that adding a :load option would complement the
> > existing :include and :joins options as follows:
>
> > * :include names associations that should be eager loaded but may also
> > be needed for sql references (e.g. in conditions, orders, etc.)
> > * :joins names associations that are needed for sql references but
> > should not be loaded
> > * :load names associations that should be loaded but are not needed
> > for sql references
>
> > Comments and discussion appreciated! When I talked with Pratik in IRC,
> > his concern was adding another explicit option when perhaps more
> > intelligence could instead be applied to existing options. This is a
> > case where it seems cleaner to add another option. Thoughts?
>
> I'd quite like to be able to preload associations after the records
> have been loaded (which is of course exactly what happens under the
> hood anyway).
>
> You get back some objects from something that has no idea what you're
> going to do, but you know that in this case you're going to be
> iterating over them and displaying the value of association X - it
> would be neat to be able to say - I'm going to be looking at X - fetch
> those objects (of course datamapper style automatic doing this could
> potentially be even better).
>
> I think this would avoid the adding of an extra option to the find
> method and actually buy you some flexability since it divorces the
> notions of loading the records and preloading an association(s)
>
> Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to