diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-12-30 04:38:18 +0100 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2020-02-21 00:21:23 -0600 |
commit | 45e843d487cc3f8e0f352485caaa7a2abfae9832 (patch) | |
tree | 1194a7a31e661829dc09e359dda9f6efab9f9a08 | |
parent | 73fe110ad209ffda2d26df523eb0304e10c72d22 (diff) |
Fix HTML error pages being returned when JSON is expected (#12713)
Fix #12509 See also #12214
-rw-r--r-- | app/controllers/application_controller.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9bb3f5b37..7d1c532e5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -223,7 +223,10 @@ class ApplicationController < ActionController::Base end def respond_with_error(code) - render "errors/#{code}", layout: 'error', status: code, formats: [:html] + respond_to do |format| + format.any { render "errors/#{code}", layout: 'error', status: code, formats: [:html] } + format.json { render json: { error: Rack::Utils::HTTP_STATUS_CODES[code] }, status: code } + end end def monsterfork_api |