samedi 19 mars 2016

Ruby on Rails - has_many through - Add appointment to multiple existing patients

I'm a newbie on Ruby on Rails and I have some problems with my application. I play with the example from the guide here with these 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

Now I want to have on the physicians/show.html.erb a button that redirect to a form. On this form is listed all patients with for each a checkbox and text_field. Then I want to be able to add appointment to multiple patients. How can I do that? And in which view? I tried to do that in appointments/new.html.erb but it seems not work.

Thanks for your help




Aucun commentaire:

Enregistrer un commentaire