我对车型设置:许多一对多:的has_many:通过和用户表关系问题导轨4
class Doctor < ActiveRecord::Base
has_many :appointments
has_many :patients, :through => :appointments
end
class Appointment < ActiveRecord::Base
belongs_to :doctor
belongs_to :patient
end
class Patient < ActiveRecord::Base
has_many :appointments
has_many :physicians, :through => :appointments
end
在我的应用程序LogedIn-用户是无论是医生,病人或我得到了管理员明白如何医生,并与预约医患关系的工作,但如何建立用户模型,并表为
class User_type < ActiveRecord::Base
belongs_to :doctors, class_name: "USER"
belongs_to :patients, class_name: "USER"
end
我知道我在这里失去了关键的自我协会,但我怎么能做到这一点,或任何其他方式为此设置这些模型和表格。提前致谢。
我纠正了错字,但我在这里的实际问题是关于模型和表,如果用户,它是什么样子 – 2014-12-07 13:21:53