0
關係如下創建我有用戶,教師和課堂教學中的模型使用STI性病孩子
class User < ApplicationRecord
end
class Teacher < User
has_many :class_rooms
end
class Student < User
has_many_and_belongs_to :class_rooms
end
class ClassRoom < ApplicationRecord
belongs_to :teachers
has_many_and_belongs_to :students
end
我的問題:如何創建遷移用戶,教師,學生和教室之間的所有關係?
例如應class_rooms具有forignKey列instructor_id或user_id說明