Nested Non RESTful controllers #753

zamith opened this Issue Oct 1, 2012 · 4 comments

3 participants


If I do

can :roll, :logs if user.admin?

it works fine, but what if logs is nested in an admin module then it should be something like:

can :roll, :admin_logs

but the authorize_resource :class => false automatic recognition won't care if it is nested or not.


CanCan works best when everything is in the same namespace. If you need to define abilities across namespaces it's best to work from a separate ability model. There's a nice wiki article, Admin Namespaces available that discusses this in more detail.

Were you able to resolve your issue? If so, please respond and we'll ask @ryanb to close this issue.


I solved by passing the class name to the load resource:

load_and_authorize_resource :class => "Admin::Log"

But yeah, it makes sense not to infer the namespace name automatically, as the controller and model namespace may not always be the same.



Great, glad you were able to get it working.

@ryanb this issue can be closed.


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!

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