Appointment Timetable in Rails

I am reading a rail relations tutorial http://guides.rubyonrails.org/association_basics.html

I want to expand this model according to my needs:

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

How do I create a model that has_manyassociates withPhysician

For instance:

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

class Availableappointment < ActiveRecord::Base
  belongs_to :physician
end

I don’t understand how to store different time frames in the model? Suppose a doctor is available from 8 a.m. to 3 p.m. with each appointment for 30 minutes (8: 30-9, 9-9: 30, 9: 30-10) ... how can I store this information in a database or Availableappointmentmodel

+3
source share
1 answer

First, I would rename AvailableProintment to Availability.

30- . , . , , , / .

, . , .

0

All Articles