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

authorize_resource doesn't work with namespaced controllers anymore #737

Open
edison opened this Issue Sep 3, 2012 · 2 comments

Comments

Projects
None yet
3 participants

edison commented Sep 3, 2012

Hello,

Extracting from Wiki...

...
If the model class is namespaced differently than the controller you will need to specify the :class option.

class ProductsController < ApplicationController
  load_and_authorize_resource :class => "Store::Product"
end

In previous versions, when we had a controller like Store::ProductsController, load_and_authorize_resource worked automatically without setting attribute class. Why cannot Cancan do this anymore?

tricon commented Oct 27, 2012

Additionally, CanCan is expecting a certain naming convention for updating the ivar with params on create. However, Rails' form_for does not expand namespaced resources implicitly. In other words, the form fields will still be, product, not, store_product.

Thus, when using this in a namespaced, mountable engine, one must use on the forms: form_for resource, :as => namespace_resource ...

xhoy commented Apr 10, 2014

Dear submitter, Since cancan/raynB hasn't been active for more than 6 months and no body else then ryam himself has commit permissions the cancan project is on a stand still.
Since cancan has several issues including missing support for rails 4 cancan is moving forward to cancancan. More details on: #994

If your feel that your pull request or bug is still applicable (and hasn't been merged in to cancan) it would be really appreciated if you would resubmit it to cancancan (https://github.com/cancancommunity/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