diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-05-24 09:55:39 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-05-24 09:55:39 +0000 |
commit | 1fd5346c3c6069e1648ccab363e25aa8e917fb5f (patch) | |
tree | c61ac849ae6c7152150486d7b70c04cca1f64f84 /app/models/member.rb | |
parent | 1914d1a15984d5f255d76ba3d40e52b290c03a83 (diff) | |
download | redmine-1fd5346c3c6069e1648ccab363e25aa8e917fb5f.tar.gz redmine-1fd5346c3c6069e1648ccab363e25aa8e917fb5f.zip |
Fixed that Member#destroy triggers after_destroy callbacks twice (#16795).
git-svn-id: http://svn.redmine.org/redmine/trunk@13140 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/member.rb')
-rw-r--r-- | app/models/member.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/member.rb b/app/models/member.rb index 76c91febf..c5d943bae 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -73,6 +73,18 @@ class Member < ActiveRecord::Base member_roles.detect {|mr| mr.inherited_from}.nil? end + def destroy + if member_roles.reload.present? + # destroying the last role will destroy another instance + # of the same Member record, #super would then trigger callbacks twice + member_roles.destroy_all + @destroyed = true + freeze + else + super + end + end + def include?(user) if principal.is_a?(Group) !user.nil? && user.groups.include?(principal) |