Optimise in what sense? If this is about solving the N + 1 query problem
then try:

blogs = Blog.include(:posts).limit(30)

This should load associated posts with only 1 query.
-- 
Greg Navis
I help tech companies to scale Heroku-hosted Rails apps.
Free, biweekly scalability newsletter for SaaS CEOs
<http://www.gregnavis.com/newsletter/>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAA6WWt9Ryn3K6bv1gDeQwEiA%3DkhiEuH7_SQEKcq%3D7TninfpsxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to