【发布时间】:2012-03-01 08:46:51
【问题描述】:
我的 Group 模型有_许多机构和学校。
class Group
has_many :institutions
has_many :schools
end
但是我需要我的组拥有_and_belongs_to_many :users 但我希望通过这样的机构和学校关联的所有用户:
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
显然这是不可能的,我该怎么办?
【问题讨论】:
-
如何定义您的机构和学校模式?
标签: mysql ruby-on-rails ruby ruby-on-rails-3 associations