46

I need to check :read? on an object in the console, how can I do this?

RubyRedGrapefruit
  • 12,066
  • 16
  • 92
  • 193

1 Answers1

105

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

Taimoor Changaiz
  • 10,250
  • 4
  • 49
  • 53
RubyRedGrapefruit
  • 12,066
  • 16
  • 92
  • 193