Cancel Security Check Error Message for SecurePassword

Possible duplicate:
Full Authentication Error Message with Rails

I play with Rails 3.1rc1 and I think that SecurePassword will be useful for me. But I don't like the default error message, Password digest can't be blank . If I called validates_presence_of :password_digest myself, I could pass :message => "Password can't be blank" , but because he is not sure in the structure how to redefine the message, delete the word "digest" , which will only confuse the user joe . Does anyone know how to do this?

Edit:

I tried adding "override": validates_presence_of as follows:

 class User < ActiveRecord::Base attr_accessible :email, :password has_secure_password validates_presence_of :password_digest, :message => "Password can't be blank" end 

But when you try to send an empty password, you just get double errors:

Invalid form

  • Digest Password Cannot Be Empty
  • Digest Password Password cannot be empty
+7
source share
2 answers

I believe that you can use the Rails internationalization API to change this.

In the config / locales / en.yml file, add the following:

 en: activerecord: attributes: user: password_digest: "Password" 

If your model class is something other than a β€œuser,” you need to change this line accordingly.

Anyway, this works for me.

+19
source

All this does is add rows

 validates_confirmation_of :password validates_presence_of :password_diges 

t

If you add a line

 validates_presence_of :password_digest, :message => "Password can't be blank" 

This should work, as that is exactly what has_secure_password calls.

0
source

All Articles