From 1e7b5a56e4b71b53048e7927869f6367e3446ae7 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 12 Nov 2024 13:26:41 +0100 Subject: [PATCH] Fix the hidden error: 'private method 'current_user' called for an instance of ErrorsController' --- app/controllers/errors_controller.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index e44b5ee8b..dcdd1a7a5 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -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