问题
Using Ruby 1.9.2 and Rails 3 -
When attempting to use <%= error_messages_for 'story' %>
I get this error:
DEPRECATION WARNING: error_messages_for 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`. (called from _app_views_stories_new_html_erb__1042605186_33967248__100840187 at C:/Ruby192/shovell/app/views/stories/new.html.erb:1)
So I did what it said and ran the plugin install. However now I have an empty dynamic_form folder at vendor/plugins
. I tried using http
instead of git
with no luck. I also added a /
at the end of the URL which worked for someone else online, but with no luck.
I added gem dynamic_form
to the Gemfile
and require "dynamic_form"
to the application.rb
as well as rerun bundle install
. It shows that dynamic_form-1.1.3 is installed to `lib/ruby/gems/1.9.1/gems/' but I am still getting the same error.
回答1:
In my case, I was trying to use dynamic_form
inside of a Rails Engine that I was building.
I simply added the gem 'dynamic_form'
into my Gemfile
, did a bundle install
and added
require 'dynamic_form'
inside my lib/libname.rb
. Restarted the app, and all was well.
回答2:
The solution was as Jeremy pointed out, to simply download rails/dynamic_form on github and extract it to vendor/plugins
and rename the folder "dynamic_form". The reason it didn't work for me before was because I was using someone else's modified version of dynamic form and of course not specifying it.
来源:https://stackoverflow.com/questions/4102479/rails3-dynamic-form-plugin-not-recognized