You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your line in ability is fine, you can specify an ability on multiple models.
I don't believe you can authorize multiple models in a single authorize_resource call.
Essentially you are saying that the user has to be have ability on all 4 objects to authorize the controller action. This indicates to me that there is actually a logical parent object (that may not exist) that is composed of the 4 models above, maybe something like MdmAddress. What you probably want to do is authorize on MdmAddress and then conditionally allow the user to manage parts of the Address using can? :read, MdmState in the view or strong_parameters permit array.
We are currently enhancing can? to allow you to check multiple models in #3
Rails 4 + Cancan
ability.rb
if user.is_sys_admin?
can :manage, [MdmArea, MdmCity, MdmCountry, MdmState] #Model Array
end
mdm_controller.rb
authorize_resource ['MdmCountry', 'MdmState', 'MdmCity', 'MdmArea'] # Not working
Please solve this ? or any solution
Thanks
The text was updated successfully, but these errors were encountered: