0

In cancan to be Able to :read all User for exemple we need

can :read,User

to be able to see a specific instance of the user we need

can :read, User do |user|
    user == something (condition satisfied ==> ability satisfied)
end

Now my question is : is it possible to check if the user can read at least one instance?? i have a menu where i have to show "users" in the menu if he can at least read one instance of a user otherwise not showing anything

Ayoub
  • 112
  • 1
  • 9
  • I guess nobody's answering because the answer depends on the exact condition you're using. If accessibility can be expressed as a scope, it's dead-simple. – D-side Oct 15 '15 at 09:02

1 Answers1

0

This worked for me:

if User.accessible_by(current_ability,:read) > 0
Undo
  • 25,519
  • 37
  • 106
  • 129
Ayoub
  • 112
  • 1
  • 9