Skip to content

Instantly share code, notes, and snippets.

@timmillwood
Created June 19, 2014 14:41
Show Gist options
  • Save timmillwood/bd503931ca80558a6ef4 to your computer and use it in GitHub Desktop.
Save timmillwood/bd503931ca80558a6ef4 to your computer and use it in GitHub Desktop.
app wide error handling
class ApplicationController < ActionController::Base
rescue_from Exception do |exception|
respond_to do |format|
format.html { redirect_to '/', :alert => exception.message }
format.js { render :js => "window.location.replace('/'); alert('#{html_escape(exception.message)}');" }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment