From 6d8b1763dfc1d5bded14cf0a9805d9fbbc791ea0 Mon Sep 17 00:00:00 2001 From: Ivan Kuchin Date: Fri, 19 Dec 2025 18:23:55 +0100 Subject: [PATCH] move check for api doc enabledness to before action Otherwise there is double render happending and it is cleaner to use a before action than to return when rendirng 404 --- app/controllers/api_docs_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/api_docs_controller.rb b/app/controllers/api_docs_controller.rb index 967f4ef89e2..084fee2f722 100644 --- a/app/controllers/api_docs_controller.rb +++ b/app/controllers/api_docs_controller.rb @@ -29,14 +29,19 @@ #++ class APIDocsController < ApplicationController - before_action :require_login + before_action :require_login, + :check_if_api_docs_enabled no_authorization_required! :index helper API::APIDocsHelper def index - render_404 unless Setting.apiv3_docs_enabled? - render locals: { turbo_opt_out: true } end + + private + + def check_if_api_docs_enabled + render_404 unless Setting.apiv3_docs_enabled? + end end