Domanda

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 ?

È stato utile?

Soluzione

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

has_many :foos, -> { includes :bar }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top