Open chrisadams opened 11 years ago
On the subject of #27, I'm still hoping for a way to eager load two reputation associations, as well evaluators.
I'm trying to eager load 2 reputation names and evaluators for a collection that's already fairly complex. When I try to use find_with_reputation
, I get undefined method find_with_reputation for #<Array:0x0000001ad17df0>
. If I call relation
on the AssociationProxy instance, I get undefined method relation for #<ActiveRecord::Relation:0x0000001c6a2018>
.
I really like how the associations are built in this gem, but lack of eager loading is really holding back search result pages in my app.
Hi, first I just want to thank you for all the hard work you're doing and have done in creating and supporting this gem.
I have a question that's almost exactly the same as this one.
In the aforementioned issue, you explained that this:
would allow you to access the reputation value like this:
without additional DB queries.
You said that code like this:
would not give you the same ability to access the reputation value without another query.
Like the author of the previous issue, I want to eagerly load reputation value, but in my case I want to do so inside of a nested eager loading hash.
My unoptimized code looks like this:
I want to write something with eager loading like this:
and then be able to access comments[0].comment_votes.
So my question is: Is there anyway to eagerly load comment_votes in the way that find_with_reputation does inside of a nested eager loading hash (i.e. Article.includes(comments: :comment_votes) )?
And if there is a way, is it also possible to include conditions on the comments?
Sorry if this is a silly question, as I'm pretty new to Rails, and thanks for any help!