3
我通过导轨协会教程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)......如何将这些信息存储在DB或Availableappointment
型号