Fix the hidden error: 'private method 'current_user' called for an instance of ErrorsController'

This commit is contained in:
Mathieu Magnin 2024-11-12 13:26:41 +01:00
parent 72d8e43b2a
commit 1e7b5a56e4
No known key found for this signature in database
GPG key ID: 8DCAFC82D7BA654E

View file

@ -23,15 +23,6 @@ class ErrorsController < ApplicationController
render_error @status
end
private
def render_error(status)
respond_to do |format|
format.html { render status: }
format.json { render status:, json: { status:, name: Rack::Utils::HTTP_STATUS_CODES[status] } }
end
end
# Intercept errors in before_action when fetching user or roles
# when db is unreachable so we can still display a nice 500 static page
def current_user
@ -45,4 +36,13 @@ class ErrorsController < ApplicationController
rescue
nil
end
private
def render_error(status)
respond_to do |format|
format.html { render status: }
format.json { render status:, json: { status:, name: Rack::Utils::HTTP_STATUS_CODES[status] } }
end
end
end