ryanb / cancan

Authorization Gem for Ruby on Rails.
MIT License
6.27k stars 784 forks source link

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

Open fran-worley opened 11 years ago

fran-worley commented 11 years ago

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 commented 11 years ago

Hi @fran-worley,

Your issue looks like a dupe of https://github.com/ryanb/cancan/issues/521#issuecomment-5696252

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 commented 10 years ago

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!