2
我有has_many機構和學校的組模型。與用戶的組直接關聯
class Group
has_many :institutions
has_many :schools
end
不過,我需要我的集團have_and_belongs_to_many:用戶,但我想一切都是通過機構和學校這樣的關聯的用戶:
class Group
has_many :institutions
has_many :users, :through => :instiutions
has_many :schools
has_many :users, :through => :schools
end
class School
belongs_to :group
has_many :educations
has_many :users, :through => :educations
end
class Institution
belongs_to :group
has_many :institutional_educations
has_many :users, :through => :institutional_educations
end
顯然這是不可能的所以我應該怎麼做?
如何定義您的院校和學校模式? – shingara 2012-03-01 08:51:05