Skip to content

Instantly share code, notes, and snippets.

@spencerldixon
Created June 12, 2019 13:44
Show Gist options
  • Save spencerldixon/8c5473d8e57bc6cda5826015dcebcaa9 to your computer and use it in GitHub Desktop.
Save spencerldixon/8c5473d8e57bc6cda5826015dcebcaa9 to your computer and use it in GitHub Desktop.
Only admins can access this
def require_admin
return if current_user.admin?
redirect_to root_path, notice: "Only admins can access this area"
end
@spencerldixon
Copy link
Author

Place this as a protected helper in your application_controller.rb file

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