Skip to content

Instantly share code, notes, and snippets.

@wdawson4
Created May 7, 2014 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wdawson4/c201be9fc652a0669832 to your computer and use it in GitHub Desktop.
Save wdawson4/c201be9fc652a0669832 to your computer and use it in GitHub Desktop.
Pundit makes the following assumptions about this class:
The class has the same name as some kind of model class, only suffixed with the word "Policy".
The first argument is a user. In your controller, Pundit will call the current_user method to retrieve what to send into this argument
The second argument is some kind of model object, whose authorization you want to check. This does not need to be an ActiveRecord or even an ActiveModel object, it can be anything really.
The class implements some kind of query method, in this case update?. Usually, this will map to the name of a particular controller action.
That's it really.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment