Internals of a permission system
(in 3 lines of code!)
Newvick Lee
Outline
Background
Background
Intro to Pundit
Using it in a controller
Creating a policy class
Pundit Internals
3 Simple Steps
Example
Model: @post�Query: :update?�Policy: PostPolicy
2. Pass in the params (user, object checking permission on)
3. Run the query method
What does public_send do?
policy.public_send(query)
policy = PostPolicy
query = update?
public_send calls the method identified by the arg (must be a public method)
Example
Model: @post�Query: :update?�Policy: PostPolicy
Thank you!