Skip to content

Instantly share code, notes, and snippets.

@stevesohcot
Created May 11, 2016 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stevesohcot/ce4154946c352be3a0c0fbdaa1ee90f2 to your computer and use it in GitHub Desktop.
Save stevesohcot/ce4154946c352be3a0c0fbdaa1ee90f2 to your computer and use it in GitHub Desktop.
Rails Admin Namespace - Base Controller
# http://stevesohcot.com/tech-lessons-learned/2016/05/11/rails-create-admin-namespace
# /app/controllers/admin/base_controller.rb
class Admin::BaseController < ApplicationController
before_action :admin_only
layout "admin"
private
def admin_only
if current_user.email != 'your_email_here@gmail.com'
redirect_to login_url, :notice => "Unauthorized"
#render :text => "Unauthorized"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment