I need to check :read? on an object in the console, how can I do this?
CanCan is an authorization library for Ruby on Rails which restricts what resources a given user is allowed to access. All permissions are defined in a single location (the Ability class) and not duplicated across controllers, views, and database queries.
CanCanCan is an authorization library for Ruby and Ruby on Rails which restricts what resources a given user is allowed to access.
You need to setup Ability object:
ability = Ability.new(current_user_object)
Now you check authorization:
ability.can? :read, object_to_be_checked
current_user_object: User object for which you want to check authorization
object_to_be_checked: is object on which you want to check authorization
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With