Re: Eager loading outside the find method

Frederick Cheung
2009-12-31T10:12:34Z

On Dec 31, 9:06 am, elioncho
<elion...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> I want to reproduce the internals of eager loading.

If you''re feeling evil you can do something like

Post.send :preload_associations @posts, :user

(This is a protected method - could easily change between releases of
rails)

Fred

>
> On 31 dic, 03:45, elioncho
<elion...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
>
> > I just want to know if its possible.
>
> > On 31 dic, 03:31, elioncho
<elion...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > Hello,
>
> > > I am used tO the :include parameter always inside a find method:
>
> > > @posts = Post.find(:all, :include => [:user])
>
> > > How can I wire the :include to the relationship outside the find
> > > method?
>
> > > @posts = Post.find(:all)
> > > @posts...(HERE THE METHOD TO WIRE UP THE USER TO EACH POST)
>
> > > Thanks

--

You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.