Adrien Siami
2013-Mar-23 12:51 UTC
ActiveRecord should eager load the parent record when fetching a relation Edit
Hi guys, I created a ticket about this issue on the github repository but I was told it''s not a bug, so here I am ! The link to the closed issue : https://github.com/rails/rails/issues/9886 The link to the example repository : https://github.com/Intrepidd/eager-loading-parent I''d love to submit a pull request for that but I''m very new in the rails edge world. What do you think ? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Richard Schneeman
2013-Mar-24 19:02 UTC
Re: ActiveRecord should eager load the parent record when fetching a relation Edit
This could potentially cause performance problems with apps that were not built
expecting this behavior. We want to stay away from features that are _too_
magical. If anything I would make the behavior "opt in" by specifying
some flag in the model like:
belongs_to :user, eager_load: true
Or as a separate method
eager_load_parent!
If this is a feature you would like, I suggest you turn it into a Gem and get
real world usage and feedback from the community.
--
Richard Schneeman
http://heroku.com
@schneems
Sent from the road
On Saturday, March 23, 2013 at 9:51 AM, Adrien Siami wrote:
> Hi guys,
>
> I created a ticket about this issue on the github repository but I was told
it''s not a bug, so here I am !
>
> The link to the closed issue : https://github.com/rails/rails/issues/9886
>
> The link to the example repository :
https://github.com/Intrepidd/eager-loading-parent
>
> I''d love to submit a pull request for that but I''m very
new in the rails edge world.
>
> What do you think ?
>
> --
> You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to rubyonrails-core+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Jeremy Kemper
2013-Mar-24 20:02 UTC
Re: ActiveRecord should eager load the parent record when fetching a relation Edit
Check out `:inverse_of` When it''s set, `foo.bars.first.foo` is automatically set to the "parent" foo. In Rails 4.1, this will be automatic when it can be detected: https://github.com/rails/rails/pull/9522 On Sat, Mar 23, 2013 at 5:51 AM, Adrien Siami <adrien.siami@gmail.com>wrote:> Hi guys, > > I created a ticket about this issue on the github repository but I was > told it''s not a bug, so here I am ! > > The link to the closed issue : https://github.com/rails/rails/issues/9886 > > The link to the example repository : > https://github.com/Intrepidd/eager-loading-parent > > I''d love to submit a pull request for that but I''m very new in the rails > edge world. > > What do you think ? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.