Rails validation error messages

RailsThere's no denying that Rails' built-in Forms Helpers are incredibly good. However if they have one flaw, it is the way error messages from validations are handled. The default messages generated by Rails are terse to say the least! If you provide your own message (with :message=>"blah blah", Rails automatically appends the name of the underlying field to the front of the message, which is restrictive and looks ugly.

I spent some time looking around for a good solution to this problem. I assumed it would be a simple configuration issue but it turns out the format of these messages is hard baked into the ActiveRecord::Errors.full_messages method.

The best solution by a mile that I found was on Adam Hooper's blog. Adam quite rightly points out that this is a fundamental internationalisation ("i18n") issue. Although his solution might seem a little more long winded than some, it is the only solution that I found that would work with multiple languages, leveraging Rails' i18n features.

Here is the full link to the article on Adam's blog.