Skip to content


@_cancan_skipper should be inherited #683

wants to merge 1 commit into from

3 participants


If a superclass controller has:

skip_load_resource :only => :index

A subclass will not skip the loading of the resource on the index action.

I've added a failing test to illustrate this behavior.

Potential fix would be to use class_attribute from Rails:


Can you try the most recent version of cancan (currently 1.6.10) to see if your issue has been resolved?

This is one of the oldest CanCan issues with no discussion. CanCan is struggling right now to implement support for rails 4, and the issue count is nearing 200. It would be a big help if we could close a few old issues and get the issue count down. Thanks!


And this is my third-oldest open pull request among my 165 total!

Kind of crazy that the tests only pass on 1.8.7 and that Travis only tests 1.8.7, too. You know it's been retired?

Anyway, this issue is not resolved. I ran the spec that this pull request adds in master, and it still fails, so the bug still exists.


Thanks for your submission! The ryanb/cancan repository has been inactive since Sep 06, 2013.
Since only Ryan himself has commit permissions, the CanCan project is on a standstill.

CanCan has many open issues, including missing support for Rails 4. To keep CanCan alive, an active fork exists at cancancommunity/cancancan. The new gem is cancancan. More info is available at #994.

If your pull request or issue is still applicable, it would be really appreciated if you resubmit it to CanCanCan.

We hope to see you on the other side!

@jpmckinney jpmckinney referenced this pull request in CanCanCommunity/cancancan

@_cancan_skipper should be inherited: add failing test #88

@jpmckinney jpmckinney closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 21 additions and 0 deletions.
  1. +21 −0 spec/cancan/controller_additions_spec.rb
21 spec/cancan/controller_additions_spec.rb
@@ -134,4 +134,25 @@
@controller_class.cancan_skipper[:load][:project].should == {:only => [:index, :show]}
@controller_class.cancan_skipper[:authorize][:project].should == {:only => [:index, :show]}
+ describe "when inheriting" do
+ before(:each) do
+ @super_controller_class =
+ @super_controller =
+ mock(@super_controller_class).helper_method(:can?, :cannot?, :current_ability)
+ @super_controller_class.send(:include, CanCan::ControllerAdditions)
+ @super_controller_class.send(:skip_load_and_authorize_resource, :only => [:index, :show])
+ @sub_controller_class =
+ @sub_controller =
+ end
+ it "sub_classes should skip the same behaviors and actions as super_classes" do
+ @super_controller_class.cancan_skipper[:load][nil].should == {:only => [:index, :show]}
+ @super_controller_class.cancan_skipper[:authorize][nil].should == {:only => [:index, :show]}
+ @sub_controller_class.cancan_skipper[:load][nil].should == {:only => [:index, :show]}
+ @sub_controller_class.cancan_skipper[:authorize][nil].should == {:only => [:index, :show]}
+ end
+ end
Something went wrong with that request. Please try again.