Ruby on Rails: How to customize validation error message? -


i have following code:

validates :name, :presence => true 

error message produced "name can't blank" instead of using actual attribute name (in case "name") want display message "registration name can't blank". how overwrite default message on validations? tried appending :message didn't work...

thanks!

in en.yml file define custom keys as:

activerecord:    attributes:     model_name:       attribute_name1: key1       attribute_name2: key2                  ...... 

this key used automatically when errors generated.

reference: http://edgeguides.rubyonrails.org/i18n.html#translations-for-active-record-models (5.1 translations active record models)


Comments

Popular posts from this blog

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -

Python __call__ special method practical example -