ryanb / cancan

Authorization Gem for Ruby on Rails.
MIT License
6.28k stars 785 forks source link

defining ability permission in a block #780

Open ghost opened 11 years ago

ghost commented 11 years ago

I am using Cancan and Rolify together.. if can write :

if admin.has_role? :manager
  can [:read, :new, :edit], Admin
  can :update, Admin, :id => admin[:id]
  cannot [:destroy, :lock, :unlock], Admin, :id => admin[:id]
  can [:update, :destroy, :lock, :unlock, :reset_passord], Admin.employees

( I defined an employees scope in Admin)

My issue comes with creating new Admin instance being only roles as employee I don't know how I can set permissions for create can :create, Admin.employees

this doesn't work ... obviously can :create, Admin works but in this case Admin :manager can role..

On create , I have a transient attribute 'manager' ( true/false ) in the form, and I also tried ability.can? :create, Admin.new(:manager => false) but this doesn't work either

any clue ?

anicholson commented 11 years ago

Have you managed to come up with a solution to this, or is it still a problem for you?

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!