开发者

Custom Validation message in Rails 3.0

开发者 https://www.devze.com 2023-04-03 21:30 出处:网络
When I use the following validation: validates_length_of :lgtitle, :maximum=>45, :message=>\"Please reduce the number of characters used in the Before Like Title. The maximum is 45 characters.

When I use the following validation:

 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 returns the message and the table row in my view:

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

What is the best practice for eliminati开发者_StackOverflow社区ng the table table row string that is added to the validation message?

Thank you.


Error messages are added in model.errors which is a Hash.

  • Keys are column names

  • Values, the message itself

I bet you display both key and value.

0

精彩评论

暂无评论...
验证码 换一张
取 消