Ordering error_messages_for in Rails
Due to laziness, I have not, in the past, given much back to the open-source community. I would like to start doing so.
For the most part, I think Rails is an elegant solution to web application development. That is why I find it shocking that error_messages_for is still unordered due to hash storage. It is a pet peeve of mine to get a form with multiple errors that do not match the order presentation by the form. It just seems sloppy.
Anyways, I took the time to write a plugin named ordered_error_messages_for. It extends the core so that if you supply :order=>[:attr1,:attr2, …] to error_messages_for(…) you get a clean orderly display of errors.
Example:
error_messages_for(:user,
:order=>[:name,:password,:phone_number])
error_messages_for(:user,
:order=>{:user=>[:name,:password,:phone_number]})
Install it with a:
./script/plugin install http://orderederrors.rubyforge.org/svn/ordered_error_messages_for
More information at:
orderederrrors on RubyForge
Sexy. Rails Sexy.


Wow,
Its workign fine thanks a lot
Posted by: ganesh | April 17, 2008 at 12:22 AM
Hi,
I have already installed another plugin i.e custom_error_messages .
and i installed your plugin .. so your plugin and also custom_error_messages plugin is not working
if you have any idea plz reply
Posted by: ganesh | April 23, 2008 at 11:42 PM
You are flippin' awesome... I've been trying to order them using nested ifs, which is hardly the Rails way, and doesn't work anyway for some unknown reason... At least this way I'll have a little more control...
I'm in total agreement that the function could use some updating... Have you thought about offering the code to Rails proper? They're just about to do a feature lock for 2.1 I think, so now would be the time if you were going to. Just a thought anyway :)
Thanks!
Posted by: Jonic | May 08, 2008 at 03:11 AM