http://guides.rubyonrails.org/association_basics.html
Based on the above example, I created:
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
Can someone guide me how can I perform a cascading delete action.
if I delete a Patient, I want all appointments for the patient deleted. Do I need to use dependent keyword somewhere ? Can someone demonstrate how to solve this.
How do I delete all appointments for a particular patient ?
Thanks in advance!