YML
en
activerecord:
errors:
models:
user:
confirmation: "Passwords do not match"
但我得到
“密码密码不匹配”
我怎么能摆脱“密码”?
答案 0 :(得分:5)
试试这个:
# config/locales/en.yml
en:
activerecord:
attributes:
user:
password_confirmation: "Passwords"
errors:
models:
user:
attributes:
password_confirmation:
confirmation: " do not match!"
答案 1 :(得分:3)
我能给出的最好的方法是从错误消息中删除该属性(所以你只收到消息) - removing field name from validation error message
这是我们在Rails 4.0.2
中使用的内容:
<% resource.errors.each do |attr,msg| %>
<li><%= msg %></li>
<% end %>