FIX: Return JSON errors for `by-external` if JSON requested

This commit is contained in:
Robin Ward 2017-04-04 16:22:14 -04:00
parent 17f2974d0a
commit 3839206317
1 changed files with 5 additions and 1 deletions

View File

@ -147,7 +147,11 @@ class ApplicationController < ActionController::Base
def rescue_discourse_actions(type, status_code, include_ember=false)
if (request.format && request.format.json?) || (request.xhr?)
show_json_errors = (request.format && request.format.json?) ||
(request.xhr?) ||
((params[:external_id] || '').ends_with? '.json')
if show_json_errors
# HACK: do not use render_json_error for topics#show
if request.params[:controller] == 'topics' && request.params[:action] == 'show'
return render status: status_code, layout: false, text: (status_code == 404 || status_code == 410) ? build_not_found_page(status_code) : I18n.t(type)