Skip to content

A platform for community discussion. Free, open, simple.

Explicitly assign primary_email record when creating a user

Guo Xiang Tan0e1b896821d1
diff --git a/app/models/user.rb b/app/models/user.rb
index f25099c27af..a2c60eb345d 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -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