2011-09-07 126 views
0

当我使用以下验证:自定义验证消息3.0

validates_length_of :lgtitle, :maximum=>45, :message=>"Please reduce the number of characters used in the Before Like Title. The maximum is 45 characters." 

Rails的返回消息,并在我看来,表行:

Lgtitle Please reduce the number of characters used in the Before Like Title. The maximum is 45 characters. 

什么是消除的最佳实践添加到验证消息的表格表格行字符串?

谢谢。

+0

不久前有类似的问题。这里是链接:http://stackoverflow.com/questions/690267/using-rails-validation-helpers-message-but-want-it-without-listing-the-column-na – christianblais

回答

1

错误消息添加在model.errors这是一个Hash

  • 键是列名

  • 值,消息本身

我敢打赌,你同时显示键和值。