ruby on rails - How to change validation messages on forms -


the website i'm developing in spanish. therefore, i'll need error messages in language.

i created file under configuration directory called 'en.yml' in order accomplish this. , added following code in it:

es:   activerecord:     errors:         models:           announcement:             attributes:              title:               blank: "el título no puede estar vacío." 

"el título no puede estar vacío" means "the title cannot blank".

when go , run code see message following:

"title el título no puede estar vacío."

where "title" field's name. don't want displayed. want display error message created.

you have specify translation after attribute

es:   activerecord:     models:       announcement: "anuncio"     attributes:       announcement:         title: "título"   # <= here     errors:       models:         announcement:           attributes:             title:               blank: "no puede estar vacío." 

see 5.1 translations activerecord models more information


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -