我使用rails generate devise user创建了一个模型用户,然后运行rake db:migrate和rake routes。但是我发现在我的主页index处出现了一个动作控制器异常错误,错误信息如下:
undefined method `devise_for' for #< ActionDispatch::Routing::Mapper:0x105371120>
我的完整跟踪如下:
config/routes.rb:2
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:233:in `instance_exec'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:233:in `draw'
config/routes.rb:1
activesupport (3.0.3) lib/active_support/dependencies.rb:235:in `load'
activesupport (3.0.3) lib/active_support/dependencies.rb:235:in `load'
activesupport (3.0.3) lib/active_support/dependencies.rb:225:in `load_dependency'
activesupport (3.0.3) lib/active_support/dependencies.rb:596:in `new_constants_in'
activesupport (3.0.3) lib/active_support/dependencies.rb:225:in `load_dependency'
activesupport (3.0.3) lib/active_support/dependencies.rb:235:in `load'
railties (3.0.3) lib/rails/application.rb:127:in `reload_routes!'
railties (3.0.3) lib/rails/application.rb:127:in `each'
railties (3.0.3) lib/rails/application.rb:127:in `reload_routes!'
railties (3.0.3) lib/rails/application.rb:120:in `routes_reloader'
activesupport (3.0.3) lib/active_support/file_update_checker.rb:32:in `call'
activesupport (3.0.3) lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
railties (3.0.3) lib/rails/application/finisher.rb:51:in `_callback_before_5'
activesupport (3.0.3) lib/active_support/callbacks.rb:419:in `_run_prepare_callbacks'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:45:in `call'
activesupport (3.0.3) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:46:in `call'
railties (3.0.3) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `synchronize'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.3) lib/rails/application.rb:168:in `call'
railties (3.0.3) lib/rails/application.rb:77:in `send'
railties (3.0.3) lib/rails/application.rb:77:in `method_missing'
rack (1.2.1) lib/rack/content_length.rb:13:in `call'
rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
rack (1.2.1) lib/rack/handler/webrick.rb:13:in `run'
rack (1.2.1) lib/rack/server.rb:213:in `start'
railties (3.0.3) lib/rails/commands/server.rb:65:in `start'
railties (3.0.3) lib/rails/commands.rb:30
railties (3.0.3) lib/rails/commands.rb:27:in `tap'
railties (3.0.3) lib/rails/commands.rb:27
script/rails:6:in `require'
script/rails:6
我的routes.eb文件内容如下:
Kliqq::Application.routes.draw do devise_for :users
(说明:该文本为原始中文文本,已经是翻译后的结果) get "home/index"
get "welcome/index"
root :to => "home#index"
end
我应该拥有一个用户控制器或类似的东西吗?谢谢,这是我的第一个Rails应用程序。