Displaying 2 results from an estimated 2 matches for "recent_comment".
Did you mean:
  recent_comments
  
2006 Jun 24
2
:limit => Parent / Child Relationship
Hi all,
I trying to find the best way to do the following and I''ll use a blog 
with comments for an example.
Blog has many comments
Comments belongs to blog
My question is how to limit the number of comments (child) records read 
for each blog (parent) record.  Most of the solutions I''ve come up with 
are limiting the number of records displayed within the views but the 
2010 Aug 05
3
how to ? Rails 3 ActiveRecord eager loading and AREL
...nts for
each articles ("includes" call in the controller handled the eager
loading).
But if you try to display only the recent comments for each article :
----------------------------------------------
- @articles.each do |article|
  = article.title
  - article.comments.recent.each do |recent_comment|
    = recent_comment.body
----------------------------------------------
Now a query is executed for every article in order to fetch it''s recent
articles.
What can I write (presumably in the "include" call) to get the eager
loading to work in this situation ?
Cheers,
M-Ryan...