Delete related exercise collection items when deleting exercises or collections

This commit is contained in:
Maximilian Grundke
2018-08-22 13:47:27 +02:00
parent 11dc48dc96
commit b5c3ce2113
2 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ class Exercise < ActiveRecord::Base
has_and_belongs_to_many :proxy_exercises has_and_belongs_to_many :proxy_exercises
has_many :user_proxy_exercise_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 :exercise_collections, through: :exercise_collection_items, inverse_of: :exercises
has_many :user_exercise_interventions has_many :user_exercise_interventions
has_many :interventions, through: :user_exercise_interventions has_many :interventions, through: :user_exercise_interventions

View File

@ -1,7 +1,7 @@
class ExerciseCollection < ActiveRecord::Base class ExerciseCollection < ActiveRecord::Base
include TimeHelper include TimeHelper
has_many :exercise_collection_items has_many :exercise_collection_items, dependent: :delete_all
alias_method :items, :exercise_collection_items alias_method :items, :exercise_collection_items
has_many :exercises, through: :exercise_collection_items, inverse_of: :exercise_collections has_many :exercises, through: :exercise_collection_items, inverse_of: :exercise_collections
belongs_to :user, polymorphic: true belongs_to :user, polymorphic: true