Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

CanCan with Inherited Resources :class override #982

Open
futbolpal opened this Issue Jan 9, 2014 · 0 comments

Comments

Projects
None yet
1 participant

I have a root controller that calls load_and_authorize_resource. One of the inheriting controllers, uses a custom model

defaults :resource_class => [THE_CUSTOM_CLASS]

CanCan works on the create, but not the index action. The load_collection? method calls resource_class method, which in turn looks at the controller name and namespace. For me, this is not correct, it should be overridden by Inherited Resources.

Adding the following to the inherited_resource.rb solves the problem for me:
16 def resource_class
17 @controller.send :resource_class
18 end

What do you think? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment