diff options
Diffstat (limited to 'app/models')
-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 |