Action Policy provides policy classes and controller helpers to authorize actions in Ruby and Rails apps. It follows a Pundit-like model with rules per resource.
Overview
Action Policy is an authorization framework for Ruby and Rails applications. It centers on resource-specific policy classes, similar in spirit to Pundit, so teams express who may perform which actions in dedicated policy objects rather than scattering checks through controllers.
Setup typically starts from an application-wide base policy with shared configuration, then per-model policies that define rules such as whether a user may update or destroy a record. In Rails, controllers call authorize helpers; failed checks raise an unauthorized error, while views can use predicate helpers to conditionally show UI.
Policies are composable with aliases, pre-checks, and scoping, with Rails integration across controllers, views, and channels. Caching avoids repeating authorization checks unnecessarily within a request. Testing matchers support RSpec and Minitest; failure reasons aid debugging, and error messages can be internationalized.
Non-Rails Ruby projects can integrate authorization as well. The gem is added via Bundler; generators can install the base policy and scaffold resource policies.
Key features
- Resource-specific policy classes
- Rails controller authorization
- View-friendly allowed-to predicates
- Policy composition and scoping
- Per-request authorization caching
- RSpec and Minitest testing matchers
- Authorization failure reason tracking
- Non-Rails Ruby usage
Use cases
- Rails controller access control
- Scoped database collections per user
- Fine-grained record update rules
- Authorization logic in plain Ruby apps