Skip to content

Instantly share code, notes, and snippets.

@olkeene
Created April 4, 2009 03:05
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 olkeene/90091 to your computer and use it in GitHub Desktop.
Save olkeene/90091 to your computer and use it in GitHub Desktop.
ajax_rescues
class ActionController::Base
private
def rescue_action_in_public(exception)
respond_to do |want|
want.html {
super(exception)
}
want.js {
render :update do |page|
page.alert "We're sorry, but something went wrong.\nWe've been notified about this issue and we'll take a look at it shortly.\n\nPlease check that any update you tried has not been successful before trying it again."
end
}
end
end
def rescue_action_locally(exception)
respond_to do |want|
want.html {
super(exception)
}
want.js {
render :update do |page|
page.alert "Oops! I made a mistake\n#{exception.class}: #{exception.message}\nCheck the logs for more detail."
end
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment