Deprecated error_messages, what to use now?

Hey,

as you all may know error_messages are deprecated:
DEPRECATION WARNING: f.error_messages was removed from Rails and is now
available as a plugin. Please install it with `rails plugin install
git://github.com/rails/dynamic_form.git`

Installing the plugin of course helps but I've been googling a bit and
stuff but couldn't find the proper new Rails 3 way of handling the error
messages. Can someone please tell me how to do it without that plugin?

I believe the idea is that you can write your own helper method to
format the errors exactly how you want them. You can access the error
messages directly by using the #errors method on the Active Record
object; for example:

person.errors.full_messages

Documentation for that is here:

http://api.rubyonrails.org/classes/ActiveModel/Errors.html

The source for the error_messages_for method in the dynamic_form
plugin might also be a source of ideas:

http://github.com/rails/dynamic_form/blob/master/lib/action_view/helpers/dynamic_form.rb#L183

Chris

Alright, thanks! Will build my own helper method then.

Ok, guys, we can write our own helper.... but why, when it is ready?

Start (with Rails 3) a new project and scaffold a dummy resource.
Then, copy the error handling from the _form partial thus generated and
adapt it to your needs.

It think it is the best way to learn how to code as an insider, provided
scaffolding is maintained by insiders.

HTH better

What do you mean by "when it is ready?" It is kinda ready :slight_smile:

I meant "if it is already done"... and I meant "previously, by someone
else", but, ok, two months is time enough for some hundreds of helpers
:slight_smile: