Why did error_messages_for disappear from Rails 3?
source link: https://www.devroom.io/2010/12/15/why-did-errormessagesfor-disappear-from-rails-3/?utm_campaign=Feed%3A+ariejan+%28ariejan%7Cdevroom.io%29
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Why did error_messages_for disappear from Rails 3?
Posted:
2010-12-15
- Last updated:
2019-06-05
Tagged rails3
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?
.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 error_messages_for
.
rails plugin install git://github.com/rails/dynamic_form.git
Just make sure to restart your server.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK