Nithin
Nithin

Reputation: 3699

devise change validation message in current_password field

Here goes my code ..

<label>Old Password</label>
 <%= f.password_field :current_password, :class=>"myaccount_textbox" %>
<label class="error" for="current_password">
 <%= validation_errors resource.errors['current_password'] %>
</label>
...........

on form-submit, with wrong password, the default validation msg - is invalid

Requirement - need to change the default msg.

devise (3.2.4) and rails 3.2.13 what I tried from link

in en.yml

en:
  activerecord:
    errors:
      models:
        user:
          attributes:
            current_password:
              confirmation: "Password is incorrect"

Currently it's not working and I get default msg only, what changes to be done, to get this fixed?

Upvotes: 3

Views: 1409

Answers (2)

Rajesh Omanakuttan
Rajesh Omanakuttan

Reputation: 6918

Try:

en:
  activerecord:
    attributes:
      user:
        current_password: "Password"
    errors:
      models:
        user:
          attributes:
            current_password:
              invalid: "is incorrect!"

OR

  devise:  
    failure:  
      invalid: 'Password is incorrect!'

Refer this link to choose the correct option for showing password incorrect message for Devise.

Upvotes: 3

Pavan
Pavan

Reputation: 33542

Try like this

# config/locales/en.yml
    en:
     activerecord:
     attributes:
     user:
         current_password: "Password"
      errors:
        models:
         user:
         attributes:
          current_password:
          confirmation: "is incorrect"

Upvotes: 0

Related Questions