diff options
author | elijah <elijah@riseup.net> | 2014-06-23 13:52:00 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2014-06-23 13:52:00 -0700 |
commit | 03b56bc0d94558ad7ff8b82e17314511a40ed16a (patch) | |
tree | d4311c3e18609ed9f0a39f815833937657a25d85 /app | |
parent | 110bc16297d7736f1025bfa85f3551313e913d84 (diff) |
Account.create - do a User.new instead of User.create, so that we can report the errors on the object if not saved.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/account.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index bee540e..67fec58 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -16,7 +16,8 @@ class Account # Returns the user record so it can be used in views. def self.create(attrs) - @user = User.create(attrs) + @user = User.new(attrs) + @user.save if @user.persisted? @identity = @user.identity @identity.user_id = @user.id @@ -28,7 +29,7 @@ class Account rescue StandardError => ex @user.errors.add(:base, ex.to_s) ensure - if @user.persisted? && (@identity.nil? || !@identity.persisted?) + if @user && @user.persisted? && (@identity.nil? || !@identity.persisted?) @user.destroy end return @user |