http://guides.rubyonrails.org/association_basics.html
上記の例に基づいて、次のように作成しました。
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
カスケード削除アクションを実行する方法を教えてください。
患者を削除する場合、その患者のすべての予定を削除します。依存キーワードをどこかで使用する必要がありますか? 誰かがこれを解決する方法を示すことができますか?
特定の患者のすべての予約を削除するにはどうすればよいですか?
前もって感謝します!