cancan icon indicating copy to clipboard operation
cancan copied to clipboard

Check ability on Class

Open panSarin opened this issue 11 years ago • 3 comments

In wiki we can read: Important: If a block or hash of conditions exist they will be ignored when checking on a class, and it will return true. For example:

can :read, Project, :priority => 3 can? :read, Project # returns true It is impossible to answer this can? question completely because not enough detail is given. Here the class does not have a priority attribute to check on.

My question is if i can do something like can? :read, Project, :all so i can check if current ability have any conditions on Project reading or it always can read all of them ?

panSarin avatar Nov 19 '12 11:11 panSarin

And there is a way i tried to do this : https://gist.github.com/4111261 and the thing is : for each selected element, can? return false, but for can? :update, Policy, Policy.joins(:policies_users).where("policies_users.user_id != #{current_user.id} and contract_id = #{Contract.find_by_name('Agent').id}") it returns true. I do something wrong with my ability model, or i just use cancan wrong way ?

panSarin avatar Nov 19 '12 15:11 panSarin

Hi @panSarin is this still an issue for you?

qnm avatar Feb 28 '13 23:02 qnm

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!

xhoy avatar Jul 01 '14 07:07 xhoy