I installed the Rails 5 application (5.0.0.rc1) with the --api flag. It uses Warden for authentication.
Everything works, except that in the absence of Warden authentication, the response is not logged properly. The log is as follows:
Started GET "/widgets.json" for ::1 at 2016-06-14 11:38:20 +0000 Processing by WidgetsController#index as JSON Completed in 0ms (ActiveRecord: 0.0ms)
or, in production:
I, [2016-06-14T14:12:54.938271 #17625] INFO -- : [db39f895-eeb1-4861-91d0-5d52c124e37a] Completed in 1ms (ActiveRecord: 0.0ms)
Of course, he should say Completed 401 Unauthorized in... , but for some reason he does not know the response status code.
Authentication errors on sending are sent to a Rack-compatible ActionController::Metal encoded controller, which is very simple:
class UnauthorizedController < ActionController::Metal include ActionController::Head def self.call(env) @respond ||= action(:respond) @respond.call(env) end def respond head :unauthorized end end
It uses the basic head method to respond (there is no need to visualize anything), so it will presumably behave the same as when using head in a regular Rails controller. But no.
The same thing happens if I try to use redirect_to ... or render ... (after enabling the appropriate modules). So, somewhere in the rack → Rails → Warden → Admin Failure Application (controller), the response status code disappears. The logbook knows to start logging the request and knows that it has been processed because it explicitly spits out the "Completed ..." line. But something is wrong.
Any ideas on how to fix this?
ruby-on-rails logging rack warden
Flambino
source share