From 1d7e423f8698f96c5554783a26ad6d65d7fe155e Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Thu, 12 May 2022 17:04:49 -0500 Subject: [PATCH] FIX: Make read only errors respect the request format (#16741) --- app/controllers/application_controller.rb | 9 ++++++++- app/views/exceptions/read_only.html.erb | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 app/views/exceptions/read_only.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3507affa497..5afccab6ea5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -246,7 +246,14 @@ class ApplicationController < ActionController::Base rescue_from Discourse::ReadOnly do unless response_body - render_json_error I18n.t('read_only_mode_enabled'), type: :read_only, status: 503 + respond_to do |format| + format.json do + render_json_error I18n.t('read_only_mode_enabled'), type: :read_only, status: 503 + end + format.html do + render status: 503, layout: 'no_ember', template: 'exceptions/read_only' + end + end end end diff --git a/app/views/exceptions/read_only.html.erb b/app/views/exceptions/read_only.html.erb new file mode 100644 index 00000000000..eb0c0e55e86 --- /dev/null +++ b/app/views/exceptions/read_only.html.erb @@ -0,0 +1 @@ +

<%= t('read_only_mode_enabled') %>