Created
November 18, 2015 19:37
-
-
Save bufordtaylor/b11a22d6986f9a9d81c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in routes | |
namespace :admin do | |
resources :sample, only: :index | |
end | |
# app/controllers/admin/sample_controller.rb | |
class Admin::SampleController < ApplicationController | |
before_filter :authorize_admin | |
def index | |
# do shit | |
end | |
end | |
# in app/controllers/application_controller.rb | |
class ApplicationController < ActionController::Base | |
#... other shit above | |
#... | |
def authorize_admin | |
redirect_to root_url unless current_user and current_user.admin? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment