Error During Failsafe Response
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Rails 4 - Error during failsafe response: undefined method 'authenticate' for nil:NilClass up vote 2 down vote favorite 2 We have a rails 4 app in production environment, on a webrick server, that crashes regularly and returns a 500 error. The crash seems to come from the following error : Error during failsafe response: undefined method `authenticate' for nil:NilClass /usr/local/rvm/gems/ruby-2.1.2/gems/devise-3.2.2/lib/devise/controllers/helpers.rb:58:in `current_user' We've checked the helpers.rb file at line 58, and so it comes from a call to wardent.authenticate in the 'current_user' method. So we've imported the gem 'warden' in our Gemfile, but nothing changes. We also tried to change the webrick server into a 'puma' server, thinking it could come from threads, but nothing changed... The entire error is the following : Error during failsafe response: undefined method `authenticate' for nil:NilClass /usr/local/rvm/gems/ruby-2.1.2/gems/devise-3.2.2/lib/devise/controllers/helpers.rb:58:in `current_user' /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/abstract_controller/helpers.rb:53:in `current_user' /home/dev/myProject/app/views/shared/_top_menu.html.erb:23:in `_app_views_shared__top_menu_html_erb___3475115451092967008_67265400' /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/template.rb:143:in `block in render' /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:161:in `instrument' /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/template.rb:141:in `render' /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/partial_renderer.rb:306:in `render_partial' /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/partial_renderer.rb:279:in `block in render' /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.0.11/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument' /usr/local/rvm/gems/ruby-2.1.2/gems/activesupport-4.0.11/lib/active_support/notifications.rb:159:in `block in instrument' /usr/local/rvm/gems/ruby-2.1.2/gems
Sign in Pricing Blog Support Search GitHub This repository Watch 11 Star 198 Fork 35 richpeck/exception_handler Code Issues 7 Pull requests 3 Projects 0 Wiki Pulse Graphs New issue Both 404's and 500's error message's not working through exception_handler gem correclty #1 Closed toymachiner62 opened this Issue Jun 10, 2014 · 24 comments Projects None http://stackoverflow.com/questions/26803616/rails-4-error-during-failsafe-response-undefined-method-authenticate-for-ni yet Labels None yet Milestone No milestone Assignees No one assigned 5 participants toymachiner62 commented Jun 10, 2014 I'm only seeing the error message: 500 Internal Server Error If you are the administrator of this website, then please read this web application's https://github.com/richpeck/exception_handler/issues/1 log file and/or the web server's log file to find out what went wrong. When hitting both a 404, or a 500 error. Here's a stacktrace for my app. ActiveRecord::RecordNotFound (Couldn't find User with 'id'=12 [WHERE users.account_id = ?]): app/controllers/users_controller.rb:10:in `show' Processing by ExceptionHandler::ExceptionController#show as HTML Parameters: {"id"=>"12"} Account Load (0.4ms) SELECT accounts.* FROM accounts WHERE accounts.subdomain = 'ematoda' ORDER BY accounts.id ASC LIMIT 1 Rendered exception_handler/exception/show.html.erb within layouts/application (0.1ms) (0.5ms) SELECT COUNT(*) FROM roles INNER JOIN users_roles ON roles.id = users_roles.role_id WHERE users_roles.user_id = 1 AND (((roles.name = 'admin') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL))) Completed 500 Internal Server Error in 104ms Error during failsafe response: This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check. /Users/tomcaflisch/.rvm/gems/ruby-2.1.1@trakd/gems/cancan-1.6.10/lib/cancan/controller_additions.rb:261:in block in check_authorization'
/Users/tomcaflisch/.rvm/gems/ruby-2.1.1@trakd/gems/activesupport-4.1.0.rc1/lib/active_support/callbacks.rb:440:ininstance_exec' /Users/tomcaflisch/.rvm/gems/ruby-2.1.1@trakd/gems/activesupport-4.1.0.rc1/lib/active_support/callbacks.rb:440:in block in make_lambda'
/U
Fortunately, when an error occurs inside your Rails application, your rails server does not crash http://blog.siami.fr/diving-in-rails-exceptions-handling and stop serving requests. In this article, I’ll explain how rails catches exceptions that may happen in your code, and how it renders a nice error page, https://issues.jboss.org/browse/TORQUE-970 depending on the Rails environment, and how you can customise it. I won’t be talking about rescue_from, and ActionController::Rescue, but about the rack part. Remember, it’s all Rack error during ! If you read my previous article about [Rails request handling](blog.siami.fr/diving-in-rails-the-request-handling), you know that Rails is based on Rack, and uses middlewares for various things. Rails also handles exceptions with middlewares. This article will explain how exceptions are handled in a production environment. If you are interested in understanding how Rails displays errors in development error during failsafe environment, have a look at the ActionDispatch::DebugExceptions middleware. The main middleware responsible for exception rescuing is ActionDispatch::ShowExceptions Let’s have a look at the call method : def call(env) @app.call(env) rescue Exception => exception if env['action_dispatch.show_exceptions'] == false raise exception else render_exception(env, exception) end end Pretty simple, call the Rack app, and rescue all exceptions. If env['action_dispatch.show_exceptions'] is false, the exception is re-raised. It is configurable by setting : config.action_dispatch.show_exceptions = false So, what happens if the error is re-raised ? Will the server just … stop ? No. Fortunately, Web servers will catch the exceptions themselves as well. Some have their own error handlers, and some others may use Rack::ShowExceptions that will just show a backtrace and some informations. More rack ! Now let’s have a look at the render_exception method : def render_exception(env, exception) wrapper = ExceptionWrapper.new(env, exception) status = wrapper.status_code env["action_dispatch.exception"] = wrapper.exception env["PATH_INFO"] = "/#{status}" response = @exceptions_app.call(env) response[1]['X-Cascade'] == 'pass' ? pass_response(status) : response rescue Exception => failsafe_error $
ExportXMLWordPrintable Details Type: Bug Status: Open (View Workflow) Priority: Major Resolution: Unresolved Affects Version/s: 2.1.2 Fix Version/s: None Component/s: None Labels: None Environment: Mac OS X 10.8.2 (Mountain Lion) java -version java version "1.7.0_09" Java(TM) SE Runtime Environment (build 1.7.0_09-b05) Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode) Rails 3.1.6 JRuby 1.7.0 Description I'm trying to port an existing Rails app (a RESTful API built on Rails, not a "web" app per se) over to torquebox. Upon doing a "torquebox deploy" and a "torquebox run" and making a simple request to my API, I'm getting the following error in the console: 17:45:07,975 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) Error during failsafe response: ActionView::Template::Error 17:45:07,976 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) /Users/bploetz/.rvm/gems/jruby-1.7.0@sw-api/gems/actionpack-3.1.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb:1:in `___sers_bploetz__rvm_gems_jruby_______sw_api_gems_actionpack_______lib_action_dispatch_middleware_templates_rescues__request_and_response_erb___1031231318_13302' 17:45:07,976 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) org/jruby/RubyBasicObject.java:1679:in `__send__' 17:45:07,976 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) org/jruby/RubyKernel.java:2085:in `send' 17:45:07,976 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) /Users/bploetz/.rvm/gems/jruby-1.7.0@sw-api/gems/actionpack-3.1.6/lib/action_view/template.rb:144:in `render' 17:45:07,976 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) /Users/bploetz/.rvm/gems/jruby-1.7.0@sw-api/gems/activesupport-3.1.6/lib/active_support/notifications.rb:55:in `instrument' 17:45:07,976 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) /Users/bploetz/.rvm/gems/jruby-1.7.0@sw-api/gems/actionpack-3.1.6/lib/action_view/template.rb:142:in `render' 17:45:07,976 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) /Users/bploetz/.rvm/gems/jruby-1.7.0@sw-api/gems/actionpack-3.1.6/lib/action_view/renderer/template_renderer.rb:40:in `render_template' 17:45:07,976 ERROR [stderr] (http-localhost