|
|
|
|
|
by rantfoil
6330 days ago
|
|
Check out the :include parameter to find method calls in the ActiveRecord documentation. Say you have 30 blog posts, and your views reference associations to the blog post's owners. Well, views are dumb and if you call post.user on each one within a loop, you end up calling User.find 30 times. But if you do Post.find(..., :include => [:user]), Rails will know to eager load all users -- and User.find never gets called 10 times. |
|