Ruby on rails 升级到formtastic 3.1时未定义的“渴望加载”方法

Ruby on rails 升级到formtastic 3.1时未定义的“渴望加载”方法,ruby-on-rails,formtastic,Ruby On Rails,Formtastic,我在这个项目中使用Ruby 1.9.3和Rails 3.2.17。我计划升级到Rails 4,但是遇到了很多gem不兼容的问题,所以我首先尝试更新一些gem。 我正在将formtastic从2.0.2更新到3.1.3 我看到很多类似这样的弃用警告: DEPRECATION WARNING: input_class is deprecated and will be removed from Formtastic 4.0 (configure Formtastic::FormBuilder.inp

我在这个项目中使用Ruby 1.9.3和Rails 3.2.17。我计划升级到Rails 4,但是遇到了很多gem不兼容的问题,所以我首先尝试更新一些gem。 我正在将formtastic从2.0.2更新到3.1.3

我看到很多类似这样的弃用警告:

DEPRECATION WARNING: input_class is deprecated and will be removed from Formtastic 4.0 (configure Formtastic::FormBuilder.input_class_finder instead (upgrade guide on wiki: http://bit.ly/1F9QtKc )). (called from _app_views_prescriptions__fields_html_haml___278490936240938991_103076320 at /home/hegwin/Workspace/rails_projects/pharmmd/app/views/prescriptions/_fields.html.haml:7)
我遵循formtastic wiki,并将这两行添加到config/initializers/formtastic.rb

之后,当我尝试运行rspec时,它抛出了一个错误:

NoMethodError:未定义的方法“渴望加载”

/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/railtie/configuration.rb:85:in'method_missing':未定义NoMethodError的'eager_load'方法 from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/formtastic-3.1.3/lib/formtastic/namespaced_class_finder.rb:32:in'use_const_defined' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/formtastic-3.1.3/lib/formtastic/namespaced_class_finder.rb:69:in`' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/formtastic-3.1.3/lib/formtastic/namespaced_class_finder.rb:24:in`' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/formtastic-3.1.3/lib/formtastic/namespaced_class_finder.rb:1:in`' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/formtastic-3.1.3/lib/formtastic/action\u class\u finder.rb:7:in`' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/formtastic-3.1.3/lib/formtastic/action\u class\u finder.rb:1:in`' from/home/hegwin/Workspace/rails_projects/pharmmd/config/initializers/formtastic.rb:104:in`' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/zeus-0.13.3/lib/zeus/load_tracking.rb:50:in'load' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/zeus-0.13.3/lib/zeus/load_tracking.rb:50:in'load' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/zeus-0.13.3/lib/zeus/load_tracking.rb:43:in'load' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/activesupport-3.2.17/lib/active\u support/dependencies.rb:245:in'block in load' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/activesupport-3.2.17/lib/active\u-support/dependencies.rb:236:in'load\u-dependency' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/activesupport-3.2.17/lib/active\u-support/dependencies.rb:245:in'load' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/engine.rb:593:in‘block 2 levels in’ from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/engine.rb:592:in'each' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/engine.rb:592:in'block-in' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/initializable.rb:30:in'instance_exec' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/initializable.rb:30:in'run' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/initializable.rb:55:in`block in run_initializers' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/initializable.rb:54:in'each' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/initializable.rb:54:in'run_initializers' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/application.rb:136:in'initialize!' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in'method_missing' 来自/home/hegwin/Workspace/rails\u projects/pharmmd/config/environment.rb:5:in`' from/home/hegwin/Workspace/rails_projects/pharmmd/spec/spec_helper.rb:12:in'require' from/home/hegwin/Workspace/rails\u projects/pharmmd/spec/spec\u helper.rb:12:in`' from/home/hegwin/Workspace/rails\u projects/pharmmd/spec/features/patient\u edit\u medicing.feature:1:in'require' 来自/home/hegwin/Workspace/rails\u projects/pharmmd/spec/features/patient\u edit\u medicing。功能:1:in`' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in'load' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in'block in load_spec_files' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in'each' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:在“加载规范文件”中 from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/rspec-core-2.13.1/lib/rspec/core/command_-line.rb:22:in'run' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in'run' from/home/hegwin/.rvm/gems/ruby-1.9.3-p362@medpro/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in'block in autorun'

formtas知道这个问题 议会小组。有关详细信息,请参阅问题和。简言之,权宜之计是利用sepastian fork的Issue1135分支。以下是文件行:

gem 'formtastic', :git => 'git://github.com/sepastian/formtastic.git', :branch => 'issue_1135'

更好的办法是分叉该分支以创建自己的存储库。

我遇到了同样的问题。非常感谢你的帮助。我也有同样的问题。我使用的是rails 5.0.0.1、ruby 2.2.4和formtastic 3.1.4。我遵循了formtastic维基——它的工作非常完美。试一试,将rails升级到最低4.0.0,将ruby升级到最低2.0.0,这可能会奏效。希望它能帮助你!
gem 'formtastic', :git => 'git://github.com/sepastian/formtastic.git', :branch => 'issue_1135'