From 025e03857822e0014408c3f3c2d853120ac6d898 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Fri, 19 Apr 2024 13:44:11 -0600 Subject: [PATCH] Add pdf handling in render_respond_to_format_with_error_message `render_respond_to_format_with_error_message` is called both when rescuing from Pundit::NotAuthorizedError and ActiveRecord::RecordNotFound. The method works properly with .html format, but prior to this change, ActionController::UnknownFormat was thrown for .pdf format. --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 71499ae5fa..0518a79d69 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -188,7 +188,7 @@ def render_respond_to_format_with_error_message(msg, url_or_path, http_status, e respond_to do |format| # Redirect use to the path and display the error message - format.html { redirect_to url_or_path, alert: msg } + format.any(:html, :pdf) { redirect_to url_or_path, alert: msg } # Render the JSON error message (using API V1) format.json do @payload = { errors: [msg] }