使用 Rails 验证助手 :message 但不希望在 message 中列出列名 [英] Using Rails validation helpers :message but want it without listing the column name in message

查看:34
本文介绍了使用 Rails 验证助手 :message 但不希望在 message 中列出列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Rails 验证助手-

Using Rails validation helpers-

validates_xxx_of :the_column, :message => "my message"

将生成验证消息:

the_column 我的消息

有没有办法关闭列名的包含?(用任何验证辅助方法替换 xxx)

Is there a way to turn-off the inclusion of the column name? (substitute xxx with any validation helper method)

推荐答案

我知道这个问题很老了.但仅供参考,以防其他人像我一样偶然发现它.

I know this question is old. But just for reference in case someone else stumbles over it as I just did.

至少在 Rails 3.0.x(不确定早期版本)中,您可以使用 RadBrad 指示的前导 ^,而无需任何 gem/插件.

At least in Rails 3.0.x (not sure about earlier versions) you can use the leading ^ as indicated by RadBrad without the need for any gems/plugins.

这篇关于使用 Rails 验证助手 :message 但不希望在 message 中列出列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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