Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

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

Open
fran-worley opened this issue Dec 30, 2012 · 2 comments
Open

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

fran-worley opened this issue Dec 30, 2012 · 2 comments

Comments

@fran-worley
Copy link

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.

@qnm
Copy link

qnm commented Feb 26, 2013

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
Copy link

xhoy commented Jul 1, 2014

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants