0

I'm looking for a clean way to change a validation failure message globally throughout all models, all attributes, etc.. in a Ruby on Rails 3 application. Something like changing "can't be blank" to "is required".

I already found out about the locale file but I'd rather not have to add each attribute of each model in the application to a list and then have to maintain it. It sounds way too complicated for something so seemingly simple.

Is there a good way of doing this?

Pigueiras
  • 18,778
  • 10
  • 64
  • 87
  • 1
    Rails allows setting the default global error messages in the config locale file. See answers to these questions: http://stackoverflow.com/questions/3808361/where-are-default-validation-error-messages-in-rails-3-0 and http://stackoverflow.com/questions/1538212/changing-default-error-messages-in-rails – Noah Harrison Mar 11 '13 at 21:39
  • Thanks.. thats what I was looking for. Didn't think to use those search terms. – user2112648 Mar 11 '13 at 23:00

2 Answers2

1

Noah Miller provided the answer to my question in the comments..

It seems this question is a duplicate of:

Where are Default Validation Error Messages in Rails 3.0?

and

Changing default error messages in Rails

Community
  • 1
  • 1
0

There is a project to i18n rails. You can follow the instructions in their page or simply download your preferred locale yaml.

This will solve your problem with Can't be blank and all the future problems that you will have with the language.

Pigueiras
  • 18,778
  • 10
  • 64
  • 87