Question

I'm Trying to see what it would take to update our project to Rails 4.

Right now I'm stuck because a lot of our associations use the include option.

has_many   :foos, :include => :bar

According to the documentation in ActiveRecord 3.2

:include
    Specify second-order associations that should be eager loaded when this object is loaded.

I see it's completely gone in ActiveRecord 4.

I didn't find an upgrade guide and am wondering what is the best approach ?

Was it helpful?

Solution

It's actually still possible, but in Rails 4, you need to pass a lambda:

has_many :foos, -> { includes :bar }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top