Skip to content

Instantly share code, notes, and snippets.

@rwehresmann
Created August 24, 2019 01:26
Show Gist options
  • Select an option

  • Save rwehresmann/95c98c6eb3bb7ae84a251da7a852f4d7 to your computer and use it in GitHub Desktop.

Select an option

Save rwehresmann/95c98c6eb3bb7ae84a251da7a852f4d7 to your computer and use it in GitHub Desktop.
module Admin
class ApplicationController < Administrate::ApplicationController
before_action :authenticate_admin
helper_method :current_user
def authenticate_admin
if current_user.nil? || current_user.admin? == false
flash[:alert] = 'You do not have authorization to access this page.'
redirect_to root_path
end
end
def current_user
@current_user ||= User.find_by(id: session[:user_id])
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment