summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-13 19:48:40 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-13 19:48:40 -0600
commit5c899df07753a31543f8dad725a26ccddc44dfe2 (patch)
treecc13040e9f859688ec2ec454486528394bbc1cde /app/models
parent3dae1ce143d006cc75940b746a8eb74982e6e861 (diff)
Añade método update a UserAccountsController
Diffstat (limited to 'app/models')
-rw-r--r--app/models/user_account.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/user_account.rb b/app/models/user_account.rb
index e50961b..cd99441 100644
--- a/app/models/user_account.rb
+++ b/app/models/user_account.rb
@@ -9,7 +9,8 @@
class UserAccount < ApplicationRecord
has_secure_password validations: false
validates :email, presence: true
- validates :password, presence: true
+ validates :email, uniqueness: true
+ validates :password, presence: true, if: :no_password?
validates_format_of :email,
with: /\A(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})\z/i
validates :first_name, presence: true
@@ -19,4 +20,10 @@ class UserAccount < ApplicationRecord
def full_name
"#{first_name} #{last_name}"
end
+
+ private
+
+ def no_password?
+ password_digest.nil?
+ end
end