I currently have the following:
users = User.all
comments = users.collect(&:comments)
However, if there are thousands of comments, i’d like to only collect 10 from each user to limit the number of database queries that are made. Is there a way to do this?
Or with another association in you model :
Then this will result in only two database queries: