Quickly test an ability

suggest change

If you’d like to quickly test if an ability class is giving the correct permissions, you can initialize an ability in the console or on another context with the rails environment loaded, just pass an user instance to test against:

test_ability = Ability.new(User.first)
test_ability.can?(:show, Post) #=> true
other_ability = Ability.new(RestrictedUser.first)
other_ability.cannot?(:show, Post) #=> true

More information: https://github.com/ryanb/cancan/wiki/Testing-Abilities

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Authorization with CanCan:
*Quickly test an ability

Table Of Contents
24Authorization with CanCan
55CSV