Possible Duplicate:
Fully custom validation error message with Rails
I'm playing around with Rails 3.1rc1 and think 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 it's in the framework I'm not sure how to override the message to remove the word "digest" which will only confuse joe user. Anyone know how to do this?
Edit:
Tried adding an 'overriding': validates_presence_of
like so:
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 trying to submit a blank password you just get double the errors:
Form is invalid
I believe you can use the Rails Internationalization API to change this.
In your config/locales/en.yml file, add the following:
en:
activerecord:
attributes:
user:
password_digest: "Password"
If your model class is something other than 'user', you'll need to change that line appropriately.
Anyway, this works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With