devise_for:Rails 4中的用户错误

时间:2013-07-31 15:43:47

标签: ruby-on-rails devise

我有一个问题,最近从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>'     

2 个答案:

答案 0 :(得分:1)

此问题可能是您的问题:https://github.com/rails/rails/issues/10559

建议:

  1. 删除每个模型中的attr_accessible
  2. 添加protected_attributes gem

答案 1 :(得分:1)

此处报告了相同的错误:https://github.com/rails/rails/issues/10559

我的解决方案是更新到最新的edge rails(4.0.10.beta),修复了在启动服务器时阻止显示真实错误的委托问题。

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