2017-06-27 111 views
0

我试图如何更改验证失败消息的属性名称?

validates :agree_tos, acceptance: {accept: true, message: ->(object, data) {'Terms of Service must be accepted.'}}, allow_nil: false, on: :update 

但它说

同意ToS服务条款必须接受。

我也试过

validates :agree_tos, acceptance: {accept: true, message: 'Terms of Service'}, allow_nil: false, on: :update 

Guide

回答

0

我改变了它在/config/locales/en.yml

en: 
    activerecord: 
    attributes: 
     user: 
     agree_tos: "Terms of Service" 

和使用

validates :agree_tos, acceptance: true, allow_nil: false, on: :update 

其产生

服务条款必须接受