0
votes

Im validating a form with client side validations and I also have devise, this is in my form:

    <fieldset>
    <div class="control-group">
    <%= f.label :current_password, "Old password:", :class => "control-label" %>
    <div class="controls">
      <%= f.password_field :current_password %>
    </div>
  </div>
  <div class="control-group">
    <%= f.label :password, "New password:", :class => "control-label" %>
    <div class="controls">
      <%= f.password_field :password  %>
    </div>
  </div>
  <div class="control-group">
    <%= f.label :password_confirmation, "New password, again:", :class => "control-label" %>
    <div class="controls">
      <%= f.password_field :password_confirmation  %> 
    </div>
  </div>
</fieldset>

and I have this in my model

validates_presence_of :password, :message => 'required'

validates_presence_of :password_confirmation, :message => 'required'

validates_presence_of :current_password, :message => 'required'

In the end my view shows something like this enter image description here

Why are the messages different? I would like to have all my messages to be consistent. How do I change the default message?

Thank you.

1

1 Answers

1
votes

Edit your config/locales/en.yml file, like so:

en:
  activerecord:
    errors:
      models:
        user:
          attributes:
            current_password:
              blank: "Required"

Note that you need to replace user with the actual name of your model.