Skip to content

Commit

Permalink
Add pdf handling in render_respond_to_format_with_error_message
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
aaronskiba committed May 2, 2024
1 parent 1edb6a4 commit 77fb5ae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,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] }
Expand Down

0 comments on commit 77fb5ae

Please sign in to comment.