Skip to content

Instantly share code, notes, and snippets.

@rocodev-tech
Created July 7, 2014 07:42
Show Gist options
  • Save rocodev-tech/240807115cd550012a2d to your computer and use it in GitHub Desktop.
Save rocodev-tech/240807115cd550012a2d to your computer and use it in GitHub Desktop.
app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def admin_required
current_user.admin?
end
end
@sdlong
Copy link

sdlong commented Jul 10, 2014

def admin_required
if !current_user.admin?
redirect_to root_path, alert: 'you are not admin!!'
end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment