FIX: When 410 is received, display proper error message instead of generic.

This commit is contained in:
Faisal Abbas 2015-12-30 15:45:54 +05:00
parent e45caa7e2e
commit f2480aa81f
2 changed files with 3 additions and 2 deletions

View File

@ -738,7 +738,8 @@ export default RestModel.extend({
topic.set('errorLoading', true); topic.set('errorLoading', true);
// If the result was 404 the post is not found // If the result was 404 the post is not found
if (status === 404) { // If it was 410 the post is deleted and the user should not see it
if (status === 404 || status === 410) {
topic.set('notFoundHtml', result.jqXHR.responseText); topic.set('notFoundHtml', result.jqXHR.responseText);
return; return;
} }

View File

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