Skip to content
This repository

CanCan 2.0 - Passing array of actions into can? method #798

Open
fran-worley opened this Issue · 2 comments

3 participants

fran-worley Rob Sharp xhoy
fran-worley

I have just added the 2.0 version of the gem into my rails app and noticed that

if can? [:update, :destroy], :users

which used to work fine in 1.6.8 now causes the error:

undefined method `to_sym' for [:update, :destroy]:Array

is this something that has been removed or is it something which isn't yet working?

for now I will replace my code with

if can?(:update, :users) && can?(:destroy, :users)

but it just seems a little messy in comparison.

Rob Sharp

Hi @fran-worley,

Your issue looks like a dupe of #521 (comment)

You cannot pass an array to the can? method like that. If you could, the behavior would be rather ambiguous - do you mean "can do one of these? can do all of these?"

You could use action aliases and/or custom actions to mimic the behavior you are after:
https://github.com/ryanb/cancan/wiki/Action-Aliases
https://github.com/ryanb/cancan/wiki/Custom-Actions

Please let me know if there's anything further we can do.

xhoy
xhoy commented

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
Something went wrong with that request. Please try again.