pundit-authorization

Implement multi-tenant Pundit authorization patterns for Rails models, controllers, and views.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/Grupo-AFAL/claude-plugins --skill pundit-authorization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pundit-authorization
Source: https://github.com/Grupo-AFAL/claude-plugins/tree/main/rails-tools/skills/pundit-authorization
Command: npx skills add https://github.com/Grupo-AFAL/claude-plugins --skill pundit-authorization

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

In multi-tenant Rails applications, authorization is hard to implement consistently. This skill provides reusable Pundit patterns to enforce organization scoping and guardrails across models, controllers, and views.

Core Features & Use Cases

  • ApplicationPolicy and Scope base the authorization model with default organization scoping.
  • OwnedByOrganization integration to enforce multi-tenant data isolation on models.
  • Controller and View Integration patterns to enforce policy checks and conditional UI.
  • Nested, STI, and Custom Policies coverage for common data models and complex scenarios.
  • Use Case: Ensure a user can only access and modify records within their organization and automatically scope queries via policy_scope.

Quick Start

Apply the recommended Pundit policies to a resource (e.g., Post) to enforce organization-based access.

Frequently Asked Questions about pundit-authorization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce multi-tenant authorization in a Rails application?

Multi-tenant authorization in Rails can be enforced by applying reusable Pundit patterns that scope queries by organization and guard access across models, controllers, and views.

What is the best way to scope Rails queries by organization using Pundit?

Scoping Rails queries by organization is achieved by defining a default policy scope that automatically filters records, ensuring users only access data within their own organization.

How do I handle Pundit policies for STI and nested resources in a multi-tenant app?

Pundit policies for STI and nested resources are handled by creating custom policy classes that extend the base ApplicationPolicy, ensuring organization scoping applies to complex data models.

Does this Pundit authorization approach work without external dependencies?

Yes, this Pundit authorization approach works without external dependencies, providing reusable patterns for organization scoping, ownership checks, and policy structure directly within your Rails application.

Can I enforce organization-based access control in Rails views and controllers?

Organization-based access control in Rails views and controllers is enforced by integrating policy checks before actions and using helper methods to conditionally render UI elements based on user permissions.

When do I need custom Pundit policies instead of the default ApplicationPolicy?

Custom Pundit policies are needed when dealing with nested resources, single-table inheritance models, or scenarios where the default organization scoping and ownership checks require specialized logic.