wrap merge in transaction
This commit is contained in:
parent
7935e42109
commit
8fe1e2bf71
1 changed files with 17 additions and 15 deletions
|
@ -196,6 +196,7 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def merge(old_user)
|
def merge(old_user)
|
||||||
|
transaction do
|
||||||
old_user.dossiers.update_all(user_id: id)
|
old_user.dossiers.update_all(user_id: id)
|
||||||
old_user.invites.update_all(user_id: id)
|
old_user.invites.update_all(user_id: id)
|
||||||
old_user.merge_logs.update_all(user_id: id)
|
old_user.merge_logs.update_all(user_id: id)
|
||||||
|
@ -215,6 +216,7 @@ class User < ApplicationRecord
|
||||||
merge_logs.create(from_user_id: old_user.id, from_user_email: old_user.email)
|
merge_logs.create(from_user_id: old_user.id, from_user_email: old_user.email)
|
||||||
old_user.destroy
|
old_user.destroy
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue