【问题标题】:Appointment Time schedule in RailsRails 中的预约时间安排
【发布时间】:2011-03-16 19:34:09
【问题描述】:

我正在浏览rails协会教程http://guides.rubyonrails.org/association_basics.html

我想进一步扩展这个模型以满足我的需要:

class Physician < ActiveRecord::Base
  has_many :appointments
  has_many :patients, :through => :appointments
end

class Appointment < ActiveRecord::Base
  belongs_to :physician
  belongs_to :patient
end

class Patient < ActiveRecord::Base
  has_many :appointments
  has_many :physicians, :through => :appointments
end

我应该如何制作一个has_many约会与Physician关联的模型

例如:

class Physician < ActiveRecord::Base
  has_many :appointments
  has_many :availableappointments
  has_many :patients, :through => :appointments
end

class Availableappointment < ActiveRecord::Base
  belongs_to :physician
end

我对如何在模型中存储不同的时间范围感到困惑?假设医生从上午 8 点到下午 3 点有空,每次预约时间为 30 分钟(8:30-9、9-9:30、9:30-10)......我如何将这些信息存储在数据库中或 @987654326 @模型

【问题讨论】:

    标签: ruby-on-rails activerecord


    【解决方案1】:

    首先,我会将 Availableappointment 重命名为 Availability。

    为每 30 分钟的时间段创建可用性实例。您可以以编程方式为医师预先填充它,或者医师自己将它们添加到管理部分。无论哪种方式,您都需要此视图让医师查看他的可用预约,因为可用性实例对于每个医师都是唯一的,并且医师始终可以删除/重新添加可用性。

    然后将从可视化医师可用性的视图中创建约会。根据可用性创建约会时,删除可用性。

    【讨论】:

      猜你喜欢
      • 2010-10-17
      • 2015-08-11
      • 2014-12-20
      • 2016-02-19
      • 2011-05-29
      • 2021-01-01
      • 1970-01-01
      • 2011-07-27
      • 2020-05-28
      相关资源
      最近更新 更多