1

モデル: * 人 * クラブ

関係 * メンバーシップ * 委員会

人々はクラブに参加できるべきである(メンバーシップ) 人々はクラブの理事会に参加できるべきである(委員会)

私のアプリケーションでは、これらには非常に異なる機能が含まれているため、フラグを使用して (is_board_member) などを設定することは避けたいと思います。

私は書きたいと思っています:

人々 has_many :clubs :through => :membership # :as => :member? :foreign_key => :member_id? has_many :clubs :through => :committee # as (上記)

しかし、これをつなぎ合わせる方法がよくわかりません

4

1 に答える 1

2

試す

has_many :committee_clubs, :through => :committee, :source => :clubs
has_many :membership_clubs, :through => :membership, :source => :clubs
于 2010-06-04T08:42:44.163 に答える