Error responses cleanup (#2692)

* Use respond_with_error for forbidden errors

* Wrap up common error code into single method
main
Matt Jankowski 8 years ago committed by Eugen Rochko
parent 2bd46f442d
commit 7bffd16024

@ -44,32 +44,20 @@ class ApplicationController < ActionController::Base
protected protected
def not_found def forbidden
respond_to do |format| respond_with_error(403)
format.any { head 404 }
format.html { respond_with_error(404) }
end
end end
def gone def not_found
respond_to do |format| respond_with_error(404)
format.any { head 410 }
format.html { respond_with_error(410) }
end
end end
def forbidden def gone
respond_to do |format| respond_with_error(410)
format.any { head 403 }
format.html { render 'errors/403', layout: 'error', status: 403 }
end
end end
def unprocessable_entity def unprocessable_entity
respond_to do |format| respond_with_error(422)
format.any { head 422 }
format.html { respond_with_error(422) }
end
end end
def single_user_mode? def single_user_mode?
@ -105,7 +93,12 @@ class ApplicationController < ActionController::Base
end end
def respond_with_error(code) def respond_with_error(code)
set_locale respond_to do |format|
render "errors/#{code}", layout: 'error', status: code format.any { head code }
format.html do
set_locale
render "errors/#{code}", layout: 'error', status: code
end
end
end end
end end

Loading…
Cancel
Save