# Eager loading outside the find method

**URL:** <https://www.ruby-forum.com/t/eager-loading-outside-the-find-method/180905>\
**Category:** Rails\
**Created:** [December 31, 2009, 9:33am UTC](https://www.ruby-forum.com/t/eager-loading-outside-the-find-method/180905 "2009-12-31T09:33:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [December 31, 2009, 9:33am UTC](https://www.ruby-forum.com/t/eager-loading-outside-the-find-method/180905/1 "2009-12-31T09:33:29Z")

</div>

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 removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [December 31, 2009, 9:46am UTC](https://www.ruby-forum.com/t/eager-loading-outside-the-find-method/180905/2 "2009-12-31T09:46:57Z")

</div>

I just want to know if its possible.

On 31 dic, 03:31, elioncho [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> @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 removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [December 31, 2009, 10:08am UTC](https://www.ruby-forum.com/t/eager-loading-outside-the-find-method/180905/3 "2009-12-31T10:08:01Z")

</div>

I want to reproduce the internals of eager loading.

On 31 dic, 03:45, elioncho [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 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 removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [December 31, 2009, 11:14am UTC](https://www.ruby-forum.com/t/eager-loading-outside-the-find-method/180905/4 "2009-12-31T11:14:10Z")

</div>

On Dec 31, 9:06 am, elioncho [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

> > > 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 removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
