Skip to content

Commit c325ef9

Browse files
committed
Improve method for suppressing password_digest error message
1 parent 6705d4d commit c325ef9

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

app/models/user.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ class User < ActiveRecord::Base
1616
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
1717
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX },
1818
uniqueness: { case_sensitive: false }
19-
validates :password, length: { minimum: 6 }
19+
validates :password, presence: true, length: { minimum: 6 }
2020
validates :password_confirmation, presence: true
21+
after_validation { self.errors.messages.delete(:password_digest) }
2122

2223
def feed
2324
Micropost.from_users_followed_by(self)

config/locales/en.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
33

44
en:
5-
activerecord:
6-
attributes:
7-
user:
8-
password_digest: "Password"
5+
hello: "Hello world"

0 commit comments

Comments
 (0)