Skip to content

Instantly share code, notes, and snippets.

@Mozart2234
Forked from stevesohcot/base_controller.rb
Created October 30, 2016 04:04
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 Mozart2234/dc152610bf88b2fcb2fc6db309454905 to your computer and use it in GitHub Desktop.
Save Mozart2234/dc152610bf88b2fcb2fc6db309454905 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