Eager Loading

Is there a way to specify within a model that an association should
always be loaded. For example, the classic example from the API docs:

Post.find(:all, :include => :author)

What if I ALWAYS wanted the author to be loaded whenever a Post object
was created? So, in essence, Post.find(:all) would bring back each
post with the associated author object already loaded.

Thanks!

You can set up a default scope:

http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-default-scoping

Mat

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs