Explicitly assign primary_email record when creating a user

* This looks like we're doing the same thing but
  we're debugging a race condition where a user
  can be created without an email record. Therefore,
  we prefer the more obvious method of assigning an
  association.
This commit is contained in:
Guo Xiang Tan 2018-03-09 15:59:46 +08:00
parent 5ef75c9c61
commit 0e1b896821

View File

@ -996,7 +996,7 @@ class User < ActiveRecord::Base
if primary_email
new_record? ? primary_email.email = new_email : primary_email.update(email: new_email)
else
build_primary_email(email: new_email)
self.primary_email = UserEmail.new(email: new_email, user: self, primary: true)
end
end