문제

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 ?

도움이 되었습니까?

해결책

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

has_many :foos, -> { includes :bar }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top