2017-12-12 2 views
0

을 통해 많은 우리는 나는 다음과 같은 코드를 한 5.1.4액티브 ::에 대한 HasManyThroughOrderError 협회

에 5.0.6에서 레일 버전을 업그레이드 있습니다

class Profile < ApplicationRecord 
    simple_roles 
    has_many :profile_roles 
    has_many :roles, through: :profile_roles 
end 

class ProfileRole < ApplicationRecord 
    belongs_to :role 
    belongs_to :profile 
end 

class Role < ApplicationRecord 
    has_many :profile_roles 
    has_many :profile, through: :profile_roles 
end 

나는 오류를 가지고 일을하면서 Profile.first.roles.

ActiveRecord::HasManyThroughOrderError: Cannot have a has_many :through association 'Profile#roles' which goes through 'Profile#user_roles' before the through association is defined.

은 누구도 날이에 대한 모든 솔루션을 제안 할 수 있습니다.

답변

0

당신의 관계에 오타있다 :

role.rb에서가, 지금

has_many :profiles, through: :profile_roles와 함께이 일을

has_many :profile, through: :profile_roles을합니까 교체하려고?

0

그냥 오타가 아닙니다.

has_many :profile, through: :profile_roles

:profile 내가 생각 :profiles해야 하는가?

+0

이것은 @rohit 작업을 수행합니까? – SRack