我可以做这样的事情吗?
Class School < ActiveRecord::Base
has_many :courses
has_many :students, :through => courses, :through => coursesections, :through => enrollments
end
Class Course < ActiveRecord::Base
has_many :coursesections
has_one :school
end
Class CourseSection < ActiveRecord::Base
has_one :course
has_one :school, :through => courses
has_many :students, :through => enrollments
end
Class Student < ActiveRecord::Base
has_many :sections, :through => enrollments
end
Enrollment 表只有一个 student_id 和一个 section_id 用于学生注册的课程部分。