我正在关注this tutorial以使用authlogic实现身份验证。一切都很顺利,直到我试图退出。我总是收到此错误消息:
未定义的方法`destroy'为nil:NilClass
代码:
# DELETE /user_sessions/1
# DELETE /user_sessions/1.xml
def destroy
@user_session = UserSession.find
@user_session.destroy
respond_to do |format|
format.html { redirect_to(:users, :notice => 'Goodbye!') }
format.xml { head :ok }
end
end
使用调试器,我发现当我点击注销时会调用destroy
两次。所以我添加了一项检查@user_session
是否为nil
并且一切正常。问题是:我在rails中没有足够的经验来找出为什么 destroy
被调用两次。根据教程,情况应该不是这样。
接下来,我将附上一些可能相关的信息:
_header.html.erb:这是退出的链接
<% if current_user %>
<%= link_to "Edit Profile", edit_user_path(current_user.id)%>
<%= link_to "Logout", :logout%>
<% else %>
<%= link_to "Register", new_user_path%> |
<%= link_to "Login", :login %>
<% end %>
routes.rb:map / logout to UserSessionController#destroy(这与教程有所不同,因为“匹配”没有“via:”导致错误):
Notenschrank::Application.routes.draw do
resources :users, :user_sessions
match 'login' => 'user_sessions#new', :as => :login, via: [:get]
match 'logout' => 'user_sessions#destroy', :as => :logout, via: [:get]
(嗯,可能是get
不是正确的方法吗?来自脚手架代码的评论提到delete
...)
在这里,作为一个大块,来自destroy
的两个回溯。我宁愿把它作为文本文件附加,但我不知道如何:s
Started GET "/logout" for 127.0.0.1 at 2014-05-04 12:29:29 +0200
Processing by UserSessionsController#destroy as HTML
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 4 LIMIT 1
/home/markus/projects/notenschrank/app/controllers/user_sessions_controller.rb:25
@user_session && @user_session.destroy
[20, 29] in /home/markus/projects/notenschrank/app/controllers/user_sessions_controller.rb
20 # DELETE /user_sessions/1
21 # DELETE /user_sessions/1.json
22 def destroy
23 @user_session = UserSession.find
24 debugger
=> 25 @user_session && @user_session.destroy
26
27 respond_to do |format|
28 format.html { redirect_to :users, notice: 'Bye!' }
29 format.json { head :no_content }
(rdb:114) where
--> #0 UserSessionsController.destroy
at line /home/markus/projects/notenschrank/app/controllers/user_sessions_controller.rb:25
#1 ActionController::ImplicitRender.send_action(method#String)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/implicit_render.rb:4
#2 AbstractController::Base.process_action(method_name#String)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:189
#3 ActionController::Rendering.process_action
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/rendering.rb:10
#4 UserSessionsController._run__3910799261545475014__process_action__callbacks
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:18
#5 ActiveSupport::Callbacks.run_callbacks(kind#Symbol)
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80
#6 AbstractController::Callbacks.process_action
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/abstract_controller/callbacks.rb:17
#7 ActionController::Rescue.process_action
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/rescue.rb:29
#8 ActiveSupport::Notifications::Instrumenter.instrument(name#String)
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:31
#9 ActiveSupport::Notifications.instrument(name#String)
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/notifications.rb:159
#10 ActionController::Instrumentation.process_action
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/instrumentation.rb:30
#11 ActionController::ParamsWrapper.process_action
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/params_wrapper.rb:245
#12 ActiveRecord::Railties::ControllerRuntime.process_action(action#String)
at line /var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/railties/controller_runtime.rb:18
#13 AbstractController::Base.process(action#String)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:136
#14 AbstractController::Rendering.process
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/abstract_controller/rendering.rb:44
#15 ActionController::Metal.dispatch(name#String, request#ActionDispatch::Request,...)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal.rb:195
#16 ActionController::RackDelegation.dispatch(action#String, request#ActionDispatch::Request,...)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/rack_delegation.rb:13
#17 ActionDispatch::Routing::RouteSet::Dispatcher.dispatch(controller#Class, action#String,...)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:231
#18 ActionDispatch::Routing::RouteSet::Dispatcher.dispatch(controller#Class, action#String,...)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:80
#19 ActionDispatch::Routing::RouteSet::Dispatcher.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:48
#20 ActionDispatch::Journey::Router.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/journey/router.rb:71
#21 ActionDispatch::Routing::RouteSet.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:655
#22 RequestStore::Middleware.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/request_store-1.0.5/lib/request_store/middleware.rb:9
#23 Rack::ETag.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/etag.rb:23
#24 Rack::ConditionalGet.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/conditionalget.rb:25
#25 Rack::Head.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/head.rb:11
#26 ActionDispatch::ParamsParser.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/params_parser.rb:27
#27 ActionDispatch::Flash.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/flash.rb:241
#28 Rack::Session::Abstract::ID.context(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225
#29 Rack::Session::Abstract::ID.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220
#30 ActionDispatch::Cookies.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/cookies.rb:486
#31 ActiveRecord::QueryCache.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/query_cache.rb:36
#32 ActiveRecord::ConnectionAdapters::ConnectionManagement.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:626
#33 ActiveRecord::Migration::CheckPending.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:369
#34 ActionDispatch::Callbacks._run__3212301349710016163__call__callbacks
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:29
#35 ActiveSupport::Callbacks.run_callbacks(kind#Symbol)
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80
#36 ActionDispatch::Callbacks.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/callbacks.rb:27
#37 ActionDispatch::Reloader.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/reloader.rb:64
#38 ActionDispatch::RemoteIp.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/remote_ip.rb:76
#39 ActionDispatch::DebugExceptions.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/debug_exceptions.rb:17
#40 ActionDispatch::ShowExceptions.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/show_exceptions.rb:30
#41 Rails::Rack::Logger.call_app(request#ActionDispatch::Request, env#Hash)
at line /var/lib/gems/1.9.1/gems/railties-4.0.0/lib/rails/rack/logger.rb:38
#42 ActiveSupport::TaggedLogging::Formatter.tagged
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:21
#43 ActiveSupport::TaggedLogging.tagged
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:67
#44 Rails::Rack::Logger.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/railties-4.0.0/lib/rails/rack/logger.rb:21
#45 ActionDispatch::RequestId.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/request_id.rb:21
#46 Rack::MethodOverride.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/methodoverride.rb:21
#47 Rack::Runtime.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/runtime.rb:17
#48 ActiveSupport::Cache::Strategy::LocalCache::Middleware.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/cache/strategy/local_cache.rb:83
#49 Rack::Lock.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/lock.rb:17
#50 ActionDispatch::Static.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/static.rb:64
#51 Rails::Engine.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:511
#52 Rails::Application.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:97
#53 Rack::Lock.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/lock.rb:17
#54 Rack::ContentLength.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/content_length.rb:14
#55 Rails::Rack::Debugger.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/railties-4.0.0/lib/rails/rack/debugger.rb:20
#56 Rack::Handler::WEBrick.service(req#WEBrick::HTTPRequest, res#WEBrick::HTTPResponse,...)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60
#57 WEBrick::HTTPServer.service(req#WEBrick::HTTPRequest, res#WEBrick::HTTPResponse,...)
at line /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138
#58 WEBrick::HTTPServer.run(sock#TCPSocket)
at line /usr/lib/ruby/1.9.1/webrick/httpserver.rb:94
#59 at line /usr/lib/ruby/1.9.1/webrick/server.rb:191
(rdb:114) cont
Redirected to http://localhost:3000/users
Completed 302 Found in 46402ms (ActiveRecord: 0.3ms)
Started GET "/users" for 127.0.0.1 at 2014-05-04 12:30:16 +0200
Processing by UsersController#index as HTML
User Load (0.3ms) SELECT `users`.* FROM `users`
Rendered users/index.html.erb within layouts/application (6.4ms)
Rendered shared/_header.html.erb (3.8ms)
Rendered shared/_sidebar.html.erb (1.1ms)
Rendered shared/_footer.html.erb (0.2ms)
Completed 200 OK in 37ms (Views: 35.2ms | ActiveRecord: 0.3ms)
Started GET "/logout" for 127.0.0.1 at 2014-05-04 12:30:16 +0200
Processing by UserSessionsController#destroy as HTML
/home/markus/projects/notenschrank/app/controllers/user_sessions_controller.rb:25
@user_session && @user_session.destroy
[20, 29] in /home/markus/projects/notenschrank/app/controllers/user_sessions_controller.rb
20 # DELETE /user_sessions/1
21 # DELETE /user_sessions/1.json
22 def destroy
23 @user_session = UserSession.find
24 debugger
=> 25 @user_session && @user_session.destroy
26
27 respond_to do |format|
28 format.html { redirect_to :users, notice: 'Bye!' }
29 format.json { head :no_content }
(rdb:114) where
--> #0 UserSessionsController.destroy
at line /home/markus/projects/notenschrank/app/controllers/user_sessions_controller.rb:25
#1 ActionController::ImplicitRender.send_action(method#String)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/implicit_render.rb:4
#2 AbstractController::Base.process_action(method_name#String)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:189
#3 ActionController::Rendering.process_action
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/rendering.rb:10
#4 UserSessionsController._run__3910799261545475014__process_action__callbacks
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:18
#5 ActiveSupport::Callbacks.run_callbacks(kind#Symbol)
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80
#6 AbstractController::Callbacks.process_action
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/abstract_controller/callbacks.rb:17
#7 ActionController::Rescue.process_action
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/rescue.rb:29
#8 ActiveSupport::Notifications::Instrumenter.instrument(name#String)
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:31
#9 ActiveSupport::Notifications.instrument(name#String)
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/notifications.rb:159
#10 ActionController::Instrumentation.process_action
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/instrumentation.rb:30
#11 ActionController::ParamsWrapper.process_action
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/params_wrapper.rb:245
#12 ActiveRecord::Railties::ControllerRuntime.process_action(action#String)
at line /var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/railties/controller_runtime.rb:18
#13 AbstractController::Base.process(action#String)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:136
#14 AbstractController::Rendering.process
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/abstract_controller/rendering.rb:44
#15 ActionController::Metal.dispatch(name#String, request#ActionDispatch::Request,...)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal.rb:195
#16 ActionController::RackDelegation.dispatch(action#String, request#ActionDispatch::Request,...)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_controller/metal/rack_delegation.rb:13
#17 ActionDispatch::Routing::RouteSet::Dispatcher.dispatch(controller#Class, action#String,...)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:231
#18 ActionDispatch::Routing::RouteSet::Dispatcher.dispatch(controller#Class, action#String,...)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:80
#19 ActionDispatch::Routing::RouteSet::Dispatcher.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:48
#20 ActionDispatch::Journey::Router.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/journey/router.rb:71
#21 ActionDispatch::Routing::RouteSet.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:655
#22 RequestStore::Middleware.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/request_store-1.0.5/lib/request_store/middleware.rb:9
#23 Rack::ETag.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/etag.rb:23
#24 Rack::ConditionalGet.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/conditionalget.rb:25
#25 Rack::Head.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/head.rb:11
#26 ActionDispatch::ParamsParser.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/params_parser.rb:27
#27 ActionDispatch::Flash.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/flash.rb:241
#28 Rack::Session::Abstract::ID.context(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225
#29 Rack::Session::Abstract::ID.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220
#30 ActionDispatch::Cookies.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/cookies.rb:486
#31 ActiveRecord::QueryCache.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/query_cache.rb:36
#32 ActiveRecord::ConnectionAdapters::ConnectionManagement.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:626
#33 ActiveRecord::Migration::CheckPending.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:369
#34 ActionDispatch::Callbacks._run__3212301349710016163__call__callbacks
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:29
#35 ActiveSupport::Callbacks.run_callbacks(kind#Symbol)
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80
#36 ActionDispatch::Callbacks.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/callbacks.rb:27
#37 ActionDispatch::Reloader.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/reloader.rb:64
#38 ActionDispatch::RemoteIp.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/remote_ip.rb:76
#39 ActionDispatch::DebugExceptions.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/debug_exceptions.rb:17
#40 ActionDispatch::ShowExceptions.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/show_exceptions.rb:30
#41 Rails::Rack::Logger.call_app(request#ActionDispatch::Request, env#Hash)
at line /var/lib/gems/1.9.1/gems/railties-4.0.0/lib/rails/rack/logger.rb:38
#42 ActiveSupport::TaggedLogging::Formatter.tagged
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:21
#43 ActiveSupport::TaggedLogging.tagged
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:67
#44 Rails::Rack::Logger.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/railties-4.0.0/lib/rails/rack/logger.rb:21
#45 ActionDispatch::RequestId.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/request_id.rb:21
#46 Rack::MethodOverride.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/methodoverride.rb:21
#47 Rack::Runtime.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/runtime.rb:17
#48 ActiveSupport::Cache::Strategy::LocalCache::Middleware.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/activesupport-4.0.0/lib/active_support/cache/strategy/local_cache.rb:83
#49 Rack::Lock.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/lock.rb:17
#50 ActionDispatch::Static.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/middleware/static.rb:64
#51 Rails::Engine.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:511
#52 Rails::Application.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:97
#53 Rack::Lock.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/lock.rb:17
#54 Rack::ContentLength.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/content_length.rb:14
#55 Rails::Rack::Debugger.call(env#Hash)
at line /var/lib/gems/1.9.1/gems/railties-4.0.0/lib/rails/rack/debugger.rb:20
#56 Rack::Handler::WEBrick.service(req#WEBrick::HTTPRequest, res#WEBrick::HTTPResponse,...)
at line /var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60
#57 WEBrick::HTTPServer.service(req#WEBrick::HTTPRequest, res#WEBrick::HTTPResponse,...)
at line /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138
#58 WEBrick::HTTPServer.run(sock#TCPSocket)
at line /usr/lib/ruby/1.9.1/webrick/httpserver.rb:94
#59 at line /usr/lib/ruby/1.9.1/webrick/server.rb:191
软件版本:
% rails --version
Rails 4.0.0
% ruby --version
ruby 2.0.0p457 (2014-03-03) [x86_64-linux-gnu]
% bundle show authlogic
/var/lib/gems/1.9.1/gems/authlogic-3.4.1
感谢您的帮助!
编辑:这是UsersController#index的代码:
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
# GET /users
# GET /users.json
def index
@users = User.all
end