Open rajesh2210 opened 10 years ago
Hi @rajesh2210, you're looking at it wrong. You can't authorize multiple models, as the name indicates authorize_resource
authorizes one resource that it infers from the controller name (unless you pass it a class, not an array of classes). In your example I guess it would be Mdm
.
You have a couple of options here:
Mdm
constant (if there is one) only.authorize_resource
helper method.Those are the options I can think of right now, but I'm sure there are others. But remember, you can only authorize one resource at a time.
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!
Rails 4 + Cancan
Q. How to give authorize_resource at controller for multiple models ?
Example
ability.rb if user.is_sys_owner? can :manage, [MdmArea, MdmCity, MdmCountry, MdmState] end
class Admin::MdmController < ApplicationController authorize_resource :class => ['MdmArea', ' MdmCity', 'MdmCountry', 'MdmState'] # Not Working?
other code
end