2

I would like to be able to check multiple actions in a given can? method (in the controller or view).

The docs (https://github.com/CanCanCommunity/cancancan/wiki/Checking-Abilities) show the following syntax:

can? :destroy, @project

This works fine but I would like to be able to do something like this:

can? [:destroy, :another_action], @project

This doesn't work, it just returns false even though both of the actions (:destroy and :another_action) called individually return true.

Of course I could do something like the following but it's not a very concise and would get unwieldily very fast (if I needed to check more than two actions)

(can? :destroy, @project && can? :another_action, @project)

How can I check multiple actions in with a single can? call?

NateW
  • 2,101
  • 3
  • 28
  • 37

0 Answers0