我對車型設置:許多一對多:的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