From b5c3ce2113ebcd41af22a150b9d641875970f1e6 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Wed, 22 Aug 2018 13:47:27 +0200 Subject: [PATCH] Delete related exercise collection items when deleting exercises or collections --- app/models/exercise.rb | 2 +- app/models/exercise_collection.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index e36aa017..dbb38758 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -14,7 +14,7 @@ class Exercise < ActiveRecord::Base has_and_belongs_to_many :proxy_exercises has_many :user_proxy_exercise_exercises - has_many :exercise_collection_items + has_many :exercise_collection_items, dependent: :delete_all has_many :exercise_collections, through: :exercise_collection_items, inverse_of: :exercises has_many :user_exercise_interventions has_many :interventions, through: :user_exercise_interventions diff --git a/app/models/exercise_collection.rb b/app/models/exercise_collection.rb index e8b1e22b..80461e23 100644 --- a/app/models/exercise_collection.rb +++ b/app/models/exercise_collection.rb @@ -1,7 +1,7 @@ class ExerciseCollection < ActiveRecord::Base include TimeHelper - has_many :exercise_collection_items + has_many :exercise_collection_items, dependent: :delete_all alias_method :items, :exercise_collection_items has_many :exercises, through: :exercise_collection_items, inverse_of: :exercise_collections belongs_to :user, polymorphic: true