【发布时间】: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