2011-09-07 199 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

  • 鍵是列名

  • 值,消息本身

我敢打賭,你同時顯示鍵和值。