1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-05 16:24:21 +01:00
fab-manager/app/models/trainings_availability.rb

16 lines
505 B
Ruby
Raw Normal View History

2016-03-23 18:39:41 +01:00
class TrainingsAvailability < ActiveRecord::Base
belongs_to :training
belongs_to :availability
after_destroy :cleanup_availability
# when the TrainingsAvailability is deleted (from Training destroy cascade), we delete the corresponding
# availability. We don't use 'dependent: destroy' as we need to prevent conflicts if the destroy came from
# the Availability destroy cascade.
def cleanup_availability
unless availability.destroying
availability.safe_destroy
end
end
end