如何解决规范的患者/医师/预约模式中“可用性”的模型关联? 我的尝试可能是错误的:
我正在遵循最小的tutorial,总结一下,这是三种模型:
class Appointment < ActiveRecord::Base
belongs_to :physician
belongs_to :patient
end
class Physician < ActiveRecord::Base
has_many :appointments
has_many :patients,:through => :appointments
end
class Patient < ActiveRecord::Base
has_many :appointments
has_many :physicians,:through => :appointments
end
到目前为止,一切都很好。现在,我尝试添加第四个模型Availability
,该模型存储医生的可用时隙记录(以便医生可以确定何时/不可用),这样就不会向患者显示不可用的时间。 t可用)
问题是,我无法确定关联。即上述需要更改的地方。
我的尝试(可能是错误的):
- 医师具有许多可用性
- 属于医生的新可用性模型
但是我有点猜测:
class Appointment < ActiveRecord::Base
belongs_to :physician
belongs_to :patient
end
class Physician < ActiveRecord::Base
has_many :appointments
has_many :patients,:through => :appointments
has_many :availabilities
end
class Patient < ActiveRecord::Base
has_many :appointments
has_many :physicians,:through => :appointments
end
class Availability < ActiveRecord::Base
belongs_to :physician
end
`
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。