Browse Source

Fix HTML error pages being returned when JSON is expected (#12713)

Fix #12509
See also #12214
closed-social-v3
Eugen Rochko 4 years ago
committed by GitHub
parent
commit
353c94910b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      app/controllers/application_controller.rb

+ 4
- 1
app/controllers/application_controller.rb View File

@ -136,6 +136,9 @@ 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
end

Loading…
Cancel
Save