Created
October 24, 2011 00:35
-
-
Save murdoch/1308130 to your computer and use it in GitHub Desktop.
has secure password memo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# some notes on using has_secure_password | |
class User < ActiveRecord::Base | |
has_secure_password | |
attr_accessible :login_name, :password, :password_confirmation | |
# secure_password.rb already checks for presence of :password_digest | |
# so we can assume that a password is present if that validation passes | |
# and thus, we don't need to explicitly check for presence of password | |
validates :password, | |
:length => { :minimum => 6 }, :if => :password_digest_changed? | |
# secure_password.rb also checks for confirmation of :password | |
# but we also have to check for presence of :password_confirmation | |
validates :password_confirmation, | |
:presence=>true, :if => :password_digest_changed? | |
___ | |
# In `config/locales/en.yml` make sure that errors on | |
# the password_digest field refer to "Password" as it's more human friendly | |
en: | |
hello: "Hello world" | |
activerecord: | |
attributes: | |
user: | |
password_digest: "Password" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
still having
Validation failed: Password confirmation can't be blank