diff options
author | Brett Walker <brett@digitalmoksha.com> | 2017-09-20 13:33:43 +0200 |
---|---|---|
committer | Brett Walker <brett@digitalmoksha.com> | 2017-09-23 15:26:04 +0200 |
commit | 945667abd85b3b832159acda3bf1e3886175da46 (patch) | |
tree | 018f33d43cb0170c0630ff9958ff6e4178832a14 /app | |
parent | de9fb43f49689b947a3e7f3c47151e7d8b1dc30c (diff) | |
download | gitlab-ce-945667abd85b3b832159acda3bf1e3886175da46.tar.gz |
more explantion why an `after_update` was replaced with an `after_commit`
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 3be3b205ea8..57f619a083f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -529,9 +529,11 @@ class User < ActiveRecord::Base errors.add(:public_email, "is not an email you own") unless all_emails.include?(public_email) end - # note: the use of the Emails services will cause `saves` on the user object, running + # Note: the use of the Emails services will cause `saves` on the user object, running # through the callbacks again and can have side effects, such as the `previous_changes` - # hash getting cleared. + # hash and `_was` variables getting munged. + # By using an `after_commit` instead of `after_update`, we avoid the recursive callback + # scenario, though it then requires us to use the `previous_changes` hash def update_emails_with_primary_email primary_email_record = emails.find_by(email: email) if primary_email_record |