2

我最近从 Rails 3 应用程序迁移到 4 时遇到了这个问题。我在升级的其他应用程序上没有看到这个错误。

启动服务器时出现此错误。devise_for :users我意识到当路线存在时出现错误routes.rb

知道是什么导致了这个错误以及如何解决它吗?

/Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in `rescue in execute_if_updated': Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x007fc453039b10 @paths=["/Users/user/Sites/mysite/config/routes.rb"], @route_sets=[#<ActionDispatch::Routing::RouteSet:0x007fc4531562a0>]> (RuntimeError)
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
    from /Users/user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from /Users/user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
    from /Users/user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
    from /Users/user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each'
    from /Users/user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
    from /Users/user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/user/Sites/mysite/config/environment.rb:8:in `<top (required)>'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /Users/user/Sites/mysite/config.ru:3:in `block in <main>'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
    from /Users/user/Sites/mysite/config.ru:in `new'
    from /Users/user/Sites/mysite/config.ru:in `<main>'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/commands/server.rb:48:in `app'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/commands/server.rb:75:in `start'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/commands.rb:78:in `block in <top (required)>'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
    from /Users/user/.rvm/gems/ruby-2.0.0-p247@mysite/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'     
4

2 回答 2

1

这个问题可能是你的问题:https ://github.com/rails/rails/issues/10559

建议:

  1. 删除每个模型中的 attr_accessible
  2. 添加 protected_attributes gem
于 2013-07-31T16:44:04.643 回答
1

这里报告了同样的错误:https ://github.com/rails/rails/issues/10559

对我来说,解决方案是更新到最新的边缘导轨(4.0.10.beta),以修复在启动服务器时阻止显示真正错误的委托问题。

这有助于我更好地调试代码并修复由于迁移而导致的每个错误。

于 2013-07-31T17:41:11.947 回答