Rectangle 27 0

you must pass class name as string. try quoting it. or try

rescue_from CanCan::AccessDenied , :with => :login_page
private
def login_page
   redirect_to login_path
end

I just tried it and it doesn't seem to work either. How is this different from what I already have in my ApplicationController?

rescue_from 'CanCan::AccessDenied'

ruby on rails - Cancan + Devise rescue_from not catching exception - S...

ruby-on-rails ruby-on-rails-3 devise cancan
Rectangle 27 0

My Admins Controller was not < ApplicationController, so it did not load the ApplicationController rescue_from method.

ruby on rails - Cancan + Devise rescue_from not catching exception - S...

ruby-on-rails ruby-on-rails-3 devise cancan
Rectangle 27 0

controller.authorize_resource

Example: can :manage, :all

controller do
  load_and_authorize_resource :except => [:update,:index, :show, :edit]
    def scoped_collection
      end_of_association_chain.accessible_by(current_ability)
  end
end

Example: can :manage, Master::Country, :organization_branch_id => each_branch.id

ruby on rails - Cancan + Devise rescue_from not catching exception - S...

ruby-on-rails ruby-on-rails-3 devise cancan
Rectangle 27 0

My Admins Controller was not < ApplicationController, so it did not load the ApplicationController rescue_from method.

ruby on rails - Cancan + Devise rescue_from not catching exception - S...

ruby-on-rails ruby-on-rails-3 devise cancan
Rectangle 27 0

you must pass class name as string. try quoting it. or try

rescue_from CanCan::AccessDenied , :with => :login_page
private
def login_page
   redirect_to login_path
end

I just tried it and it doesn't seem to work either. How is this different from what I already have in my ApplicationController?

rescue_from 'CanCan::AccessDenied'

ruby on rails - Cancan + Devise rescue_from not catching exception - S...

ruby-on-rails ruby-on-rails-3 devise cancan
Rectangle 27 0

controller.authorize_resource

Example: can :manage, :all

controller do
  load_and_authorize_resource :except => [:update,:index, :show, :edit]
    def scoped_collection
      end_of_association_chain.accessible_by(current_ability)
  end
end

Example: can :manage, Master::Country, :organization_branch_id => each_branch.id

ruby on rails - Cancan + Devise rescue_from not catching exception - S...

ruby-on-rails ruby-on-rails-3 devise cancan