Last active
December 15, 2015 10:09
-
-
Save acnalesso/5244149 to your computer and use it in GitHub Desktop.
Create your custom controller for CanCan to skip_authorization_check
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 version: 3.2.9 | |
ruby 1.9.3p125 (2012-02-16 revision 34643) | |
devise 2.2.3 | |
[i686-linux] | |
OS: Debian Linux Lenny(I know... gonna update to Squeeze) | |
Listening to: http://www.youtube.com/watch?v=ab5hLh_Nurg&feature=share&list=RD02EXf5tcjdO8s while programming :) | |
Controller: | |
class Guards::SessionsController < Devise::SessionsController | |
before_filter :authenticate_admin! | |
load_and_authorize_resource | |
skip_authorization_check :only => [:index] | |
end | |
saved as: controllers/guards/sessions_controller.rb | |
routes.rb | |
Api::Application.routes.draw do | |
authenticated :admin do | |
root :to => 'admins#index' | |
end | |
root :to => "reception#index" | |
devise_for :admins, :controllers => {:sessions => "guards/sessions"} | |
end | |
*ERRORS I'm getting: | |
When devise rects to sign in on my browser it says: | |
http://postimg.org/image/p0zzt40b7/ | |
(an image worth a thousand words) | |
output from the live shell: | |
history | |
=> #<Set: {"/home/dummy/www/api/app/models/admin", "/home/dummy/www/api/app/helpers/application_helper", "/home/dummy/www/api/app/helpers/banner_helper", "/usr/local/lib/ruby/gems/1.9.1/gems/devise-2.2.3/app/helpers/devise_helper", "/home/dummy/www/api/app/controllers/application_controller", "/usr/local/lib/ruby/gems/1.9.1/gems/devise-2.2.3/app/controllers/devise_controller", "/usr/local/lib/ruby/gems/1.9.1/gems/devise-2.2.3/app/controllers/devise/sessions_controller", "/home/dummy/www/api/app/controllers/guards/sessions_controller"}> | |
rake routes: | |
new_admin_session GET /admins/sign_in(.:format) guards/sessions#new | |
admin_session POST /admins/sign_in(.:format) guards/sessions#create | |
destroy_admin_session DELETE /admins/sign_out(.:format) guards/sessions#destroy | |
admin_password POST /admins/password(.:format) devise/passwords#create | |
new_admin_password GET /admins/password/new(.:format) devise/passwords#new | |
edit_admin_password GET /admins/password/edit(.:format) devise/passwords#edit | |
PUT /admins/password(.:format) devise/passwords#update | |
admins GET /admins(.:format) admins#index | |
admin GET /admins/:id(.:format) admins#show | |
Thanks, have fun :) peace | |
MINSWAN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment