I would like to delete Patient and all their Appointments without deleting Physician.
Take the following association:
class Patient < ActiveRecord::Base
has_many :appointments
has_many :physicians, through: :appointments
end
class Appointment < ActiveRecord::Base
belongs_to :physician
belongs_to :patient
end
class Physician < ActiveRecord::Base
has_many :appointments
has_many :patients, through: :appointments
Every time I remove a patient, I lose all physicians that the patient has even been in contact with (via Appointment). It may be possible that the Physician has only ever seen one patient.. but that is no reason to remove the Physician when the Patient is removed.
I feel like I need something like
class Physician < ActiveRecord::Base
has_many :appointments, dependant: hell no!
Can someone help me? Is it possible that a has_many through relationship is the wrong solution all together?
Thanks
EDIT: I would never wish to remove a Patient or Physician from the system due to an associated Patient or Physician leaving the surgery.
If a Physician leaves, this doesn't mean the patient is leaving too. Though I'm happy for their appointments to be removed. And likewise if a Patient leaves, this doesn't mean my Physician is leaving also.