Skip to content

Instantly share code, notes, and snippets.

@agungyuliaji
Created February 13, 2013 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agungyuliaji/4943256 to your computer and use it in GitHub Desktop.
Save agungyuliaji/4943256 to your computer and use it in GitHub Desktop.
Get Response Code on rescue_from
# code snippet is taken from app/controllers/application_controller.rb
rescue_from Exception do |exc|
@response = Rack::Utils.status_code(ActionDispatch::ShowExceptions.rescue_responses[exc.class.name]).to_s
case @response
when "401", "404", "422"
@text = "You may have mistyped the address or the page may have moved."
when "500"
@text = "There was an internal error (failure). Please wait a few minutes and try again."
end
@message = exc.to_s.downcase
respond_to do |type|
type.html { render :template => "errors/exeptions" }
type.all { render :nothing => true }
end
true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment