Why did error_messages_for disappear from Rails 3?

| Posted: - Last updated:
| Tagged rails3
| ~200wrds (~1min)

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? ~ The reason 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?
    %h2 There was a problem saving this post

      - @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 error_messages_for.

rails plugin install git://github.com/rails/dynamic_form.git

Just make sure to restart your server.

My site is free of ads and trackers. I record privacy-respecting usage statistics with Fathom.

Was this post helpful to you? Why not ☕ Buy me a coffee or use Brave Browser to send a tip.