Rails models rails关联--我可以多次使用:through吗?
我可以这样做吗Rails models rails关联--我可以多次使用:through吗?,rails-models,Rails Models,我可以这样做吗 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 :s
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
班级学校课程,:通过=>课程部分,:通过=>注册
终止
课程课程
有很多:学生,:通过=>注册
终止
班级学生注册
终止
注册表中只有一个学生id和一个学生注册的课程部分的部分id。你知道吗?我改为使用Django/python。你知道吗?我改为使用Django/python。