Conclusion

Congratulations! You’ve built a fully authorized Rails application from the ground up using Action Policy. Starting from a completely open Help Desk app, you’ve progressively added:

  • Policies and rules — centralized authorization logic in dedicated policy classes
  • Controller integrationauthorize! to enforce access, authorized_scope to filter collections
  • View helpersallowed_to? and allowance_to for conditional UI rendering
  • Pre-checks — cross-cutting concerns like admin bypass, applied globally
  • Scopingrelation_scope to filter ActiveRecord queries per user
  • Failure reasonscheck?-based sub-rules with per-reason i18n messages
  • Testing — policy unit tests and controller integration tests

Keep exploring

The demo app on the right is fully functional—you can sign in as different users, create tickets, add comments, and see how authorization rules shape the experience. Try adding new rules or modifying existing ones to see what happens.

Here are some ideas to try:

  • Add a close? rule that only allows the ticket creator or an admin to close a ticket
  • Add a reassign? rule for agents to transfer tickets to other agents
  • Make the internal checkbox on the comment form visible only to agents

Features not covered

This tutorial focused on the most commonly used features. Action Policy has more to offer — here’s what we didn’t cover:

FeatureWhat it doesDocumentation
CachingCache policy results to avoid redundant checksCaching
NamespacesOrganize policies by namespace (e.g., Admin::TicketPolicy)Namespaces
InstrumentationHook into policy evaluation for monitoringInstrumentation
GraphQL integrationUse Action Policy with GraphQL APIsGraphQL

Visit actionpolicy.evilmartians.io for the full documentation and API reference.

Powered by WebContainers
Files
Preparing Environment
  • Preparing Ruby runtime
  • Prepare development database