更改 Rails 中的默认错误消息 [英] Changing default error messages in Rails

查看:35
本文介绍了更改 Rails 中的默认错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的客户决定,他们希望在整个应用中将所有空白 AR 错误消息从不能为空"更改为必须完成".

Our client has decided that they would like all blank AR error messages to be changed from "can't be blank" to "must be completed" throughout the entire app.

Rails 最简单的方法是什么?

What's the easiest Rails'y way of doing this?

推荐答案

使用 config/locales/en.yml

具体来说,将以下内容放入该文件中:

Specifically, put the following in that file:

en:
  activerecord:
    errors:
      messages:
        blank: "must be completed"

这篇关于更改 Rails 中的默认错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆