Created
August 6, 2015 02:06
-
-
Save baothi/75dbdd033db3e8e7c71f to your computer and use it in GitHub Desktop.
tes admin
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::AdminController < ApplicationController | |
authorize_resource :class => false | |
layout "admin" | |
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::HomeAdminController < ApplicationController | |
def index | |
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::RegistrationsController < Devise::RegistrationsController | |
# disable default no_authentication action | |
skip_before_action :require_no_authentication, only: [:new, :create, :cancel] | |
# now we need admin to register new admin | |
prepend_before_action :authenticate_scope!, only: [:new, :create, :cancel] | |
layout "admin" | |
protected | |
def after_sign_up_path_for(resource) | |
signed_in_root_path(resource) | |
end | |
def after_update_path_for(resource) | |
signed_in_root_path(resource) | |
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
Rails.application.routes.draw do | |
resources :locations | |
get 'registrations/update' | |
devise_for :users | |
resources :profiles do | |
# member do | |
# path 'update_image' | |
# end | |
end | |
resources :users do | |
end | |
get 'home/index' | |
root 'home#index' | |
devise_for :admin, controllers: { sessions: "admin/sessions" ,registrations: 'admin/registrations'} | |
namespace :admin do | |
root to: "home_admin#index" | |
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::SessionsController < Devise::SessionsController | |
layout "admin" | |
protected | |
def after_sign_in_path_for(resource) | |
session[:admin_return_to].blank? ? admin_root_path : session[:admin_return_to] | |
end | |
def after_sign_out_path_for(resource_or_scope) | |
new_admin_session_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rails.application.routes.draw do
resources :locations
get 'registrations/update'
devise_for :users
resources :profiles do
# member do
# path 'update_image'
# end
end
resources :users do
end
get 'home/index'
root 'home#index'
devise_for :admins, controllers: { sessions: "admins/sessions" ,registrations: 'admins/registrations'}
namespace :admins do
root to: "home_admin#index"
end
end