How to change validation messages on forms

后端 未结 1 2053
春和景丽
春和景丽 2021-02-10 15:58

the website I\'m developing will be in spanish. Therefore, I\'ll need the error messages in that language.

I created a file under Configuration directory called \'en.yml

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-10 16:38

    You have to specify the translation after the 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 for ActiveRecord Models for more information

    0 讨论(0)
提交回复
热议问题