Created
May 11, 2012 08:42
-
-
Save Antiarchitect/2658441 to your computer and use it in GitHub Desktop.
Single entry point for many scopes in Devise.
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
class ApplicationController < ActionController::Base | |
... | |
private | |
def after_sign_in_path_for(resource) | |
if current_administrator && current_administrator.is_admin? | |
[:admin, :admins] | |
else | |
root_path | |
end | |
end | |
def after_sign_out_path_for(resource) | |
case resource | |
when :administrator | |
[:new, :administrator, :session] | |
else | |
root_path | |
end | |
end | |
end |
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
class Admin::BaseController < ApplicationController | |
respond_to :html, :json, :xml | |
before_filter :authenticate_admin! | |
private | |
def authenticate_admin! | |
authenticate_administrator! | |
unless current_administrator && current_administrator.is_admin? | |
respond_with current_administrator, location: after_sign_out_path_for(:administrator) | |
end | |
end | |
end |
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
Myapp::Application.routes.draw do | |
devise_for :administrators | |
namespace :admin do | |
resources :admins | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment