Skip to content

Docs: use idiomatic Pundit/CanCanCan authorization recipes - #39

Merged
phaedryx merged 1 commit into
mainfrom
auth-helpers
Jul 2, 2026
Merged

Docs: use idiomatic Pundit/CanCanCan authorization recipes#39
phaedryx merged 1 commit into
mainfrom
auth-helpers

Conversation

@phaedryx

@phaedryx phaedryx commented Jul 2, 2026

Copy link
Copy Markdown
Member

The Pundit recipe hardcoded the policy class (UserPolicy.new); use Pundit.policy! so the record drives policy lookup, matching how a controller resolves it. The CanCanCan recipe built Ability.new inside the action; inject current_ability instead, since can?/authorize! already delegate to it. Switch the example resource from User to Project so the actor (current_user) and the authorized object are visually distinct.

The Pundit recipe hardcoded the policy class (UserPolicy.new); use
Pundit.policy! so the record drives policy lookup, matching how a
controller resolves it. The CanCanCan recipe built Ability.new inside
the action; inject current_ability instead, since can?/authorize!
already delegate to it. Switch the example resource from User to
Project so the actor (current_user) and the authorized object are
visually distinct.
@phaedryx
phaedryx merged commit cae9c06 into main Jul 2, 2026
4 checks passed
@phaedryx
phaedryx deleted the auth-helpers branch July 2, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant