I'm playing with an example from Rails Guides:
http://guides.rubyonrails.org/association_basics.html#the-has_many-through-association
This example has the following setup for the models:
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
I'm trying to understand how to do the following two things:
- How do I setup the view that would create a new Patient and assign an Appointment to them with an existing Physician with an Appoint Time
- How do I assign an existing Patient an Appointment with a new Physician and an Appointment Time
I went through the RailsCasts 196 & 197 that deal with nested forms, but I don't see how it would apply to this situation.
Can someone provide an example or point me to a guide on this please?
Thank you