Skip to content

Instantly share code, notes, and snippets.

@uhhuhyeah
Created June 24, 2011 15:35
Show Gist options
  • Save uhhuhyeah/1045040 to your computer and use it in GitHub Desktop.
Save uhhuhyeah/1045040 to your computer and use it in GitHub Desktop.
rescue_from in application_controller
class ApplicationController < ActionController::Base
include Rack::OAuth::Methods
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
rescue_from OAuth::Unauthorized, :with => :oauth_unauthorized
private
def record_not_found
render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404
end
def oauth_unauthorized
Rails.logger.error "oauth_unauthorized called. Redirecting to login_path..."
redirect_to login_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment