2008-03-12

The default Rails way of doing validate error messages is sort of silly. It works, but it doesn't work that well. You can iterate through all the error messages in a very constrained way (error_messages_for) or you can display errors on fields one by one (error_message_on). I kind of want functionality from both. Basically my problem is that I have fields named differently on the backend than I want them displayed on the frontend.

One way around it is with this old plugin I found called Custom Error Message. You can get it here on rubyforge: custom-err-msg @ rubyforge. Just extract it to your /vendor/plugins directory and slap a ^ in front of your messages. Works with Rails 2.0.2.

It's some extremely simple, but brilliant code that changes how ActiveRecord::Errors::full_messages works.

Leave a Reply