2011-11-04 2 views
2

나는 모델을 여러 부자에 가입하고 그 다음이 수 또는 레일 규칙이었다 궁금 해서요 :풍부한 협회 레일

has_many :users through => rich_association_one 
has_many :rich_association_one 

has_many :users through => rich_accociation_two 
has_many :rich_association_two 

감사

답변

4

이 가능하다,하지만 난 당신이 생각 다른 별칭을 사용해야합니다. 예상대로, has_many :users을 두 번 호출하면 모델에 파멸을 초래할 것입니다.

은 다음과 같이 뭔가를 시도 : has_many 옵션에 대한

has_many :rich_association_one 
has_many :association_one_users, 
     :through => :rich_association_one, 
     :class_name => "User" 

has_many :rich_association_two 
has_many :association_two_users, 
     :through => rich_accociation_two, 
     :class_name => "User" 

기본적인 정보는 RoR guides에 사용할 수 있습니다.