Created
February 13, 2013 09:17
-
-
Save agungyuliaji/4943256 to your computer and use it in GitHub Desktop.
Get Response Code on rescue_from
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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