Add before_destroy :cancel to precent role destroy.Change Conference-Role association to have dependent: :destroy_all

This commit is contained in:
Nishanth Vijayan 2016-03-11 20:44:09 +05:30
parent 2df6d1039f
commit 48b48e88ac
2 changed files with 10 additions and 2 deletions

View file

@ -4,7 +4,8 @@ class Conference < ActiveRecord::Base
require 'uri'
serialize :events_per_week, Hash
# Needed to call 'Conference.with_role' in /models/ability.rb
resourcify
# Dependent destroy will fail as roles#destroy will be cancelled,hence delete_all
resourcify :roles, dependent: :delete_all
default_scope { order('start_date DESC') }