My setup for the models:
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
In my application LogedIn-User IS A either doctor,patient or the Admin i got understand that how Doctor and patient relationship work with appointment,But how to setup the user model and table for that
class User_type < ActiveRecord::Base
belongs_to :doctors, class_name: "USER"
belongs_to :patients, class_name: "USER"
end
I know that I am missing crucial self association here but how can i do that, or any other way to set up these models and tables for that. Thanks in advance.