Reputation: 937
I have a table called vital_sign which belongs to a patient (the patient has multiple vital signs) and to a physician (the physician captured this vital sign), but I don't care about getting physician.vital_signs, how do I express it in rails models?
I suspect something like this:
Is this correct?
Upvotes: 0
Views: 84
Reputation: 963
You can try this :
class Physician < ActiveRecord::Base
has_many :appointments
has_many :patients, through: :vital_signs
end
class VitalSign < ActiveRecord::Base
belongs_to :physician
belongs_to :patient
end
class Patient < ActiveRecord::Base
has_many :appointments
has_many :physicians, through: :vital_signs
end
Upvotes: 0