Why did error_messages_for disappear from Rails 3?
Today I learned that
error_messages_for has disappear from Rails 3. When I tried using it I got the following deprecation warning:
DEPRECATION WARNING: form.error_messages was removed from Rails and is now available as a plugin.
What happened? Why was this pulled from Rails 3?
error_messages_for was pulled from Rails 3 is a new guideline that says that nothing in Rails Core should dictate the look and feel of an app.
Okay, that’s all well and good. How do you fix this problem? There are two ways. The first is to implement your own error handling. A HAML snippet:
- if @post.errors.any? .errors %h2 There was a problem saving this post %ul - @post.errors.full_messages.each do |msg| %li= msg
This is by far the best way to go about it. However, if you have a current Rails 2 app you’re upgrading, writing your own error handling may be rather difficult or time consuming. In that case you can install a plugin that restores the original functionality of
rails plugin install git://github.com/rails/dynamic_form.git
Just make sure to restart your server.