Skip to content

Instantly share code, notes, and snippets.

@jstewart
Created February 7, 2011 19:35
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 jstewart/815024 to your computer and use it in GitHub Desktop.
Save jstewart/815024 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
before_filter :authenticate_user!
before_filter :authorize_admin
rescue_from UserNotAuthorized, :with => :handle_auth_exception
private
def handle_auth_exception
render :text => "401 Not Authorized", :status => :unauthorized
end
def authorize_admin
raise UserNotAuthorized unless current_user.is_admin?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment