Ruby on rails 我怎样才能完全改变;密码不存在';t匹配确认“;错误消息activerecord

Ruby on rails 我怎样才能完全改变;密码不存在';t匹配确认“;错误消息activerecord,ruby-on-rails,activerecord,Ruby On Rails,Activerecord,yml 但我明白了 “密码不匹配” 我怎样才能摆脱“密码” 试试这个: en activerecord: errors: models: user: confirmation: "Passwords do not match" 我所能提供的最好方法是从错误消息中删除该属性(因此您只能获得该消息)—— 这就是我们在Rails 4.0.2中使用的内容: # config/locales/en.yml en: activere

yml

但我明白了

“密码不匹配”

我怎样才能摆脱“密码”

试试这个:

en   
  activerecord:
    errors: 
      models: 
        user:
          confirmation: "Passwords do not match"

我所能提供的最好方法是从错误消息中删除该属性(因此您只能获得该消息)——

这就是我们在Rails 4.0.2中使用的内容:

# config/locales/en.yml
en:
  activerecord:
    attributes:
      user:
        password_confirmation: "Passwords"
    errors:
      models:
        user:
          attributes:
            password_confirmation:
              confirmation: " do not match!"


  • 您正在验证哪个字段?请提供字段名。是否是
    password\u confirmation
    ?这也可能会将字段的标签更改为“Passwords”,具体取决于表单的生成方式。不管怎样,这都不是正确的方法。这也是另一种选择。因此,它是重复的,应该标记为重复。
    <% resource.errors.each do |attr,msg| %>
        <li><%= msg %></li>
    <% end %>