afal-concerns

Create ActiveSupport::Concerns for Rails models with scoping, audit trails, and evidence attachments.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Reduce duplicated model logic and ensure consistent multi-tenant scoping, audit trails, and evidence attachments by guiding developers to extract cohesive behavior into well-structured ActiveSupport::Concerns that integrate with the AFAL stack.

Core Features & Use Cases

  • Guidance on standard concern anatomy (included block, class_methods, instance methods) and composition order.
  • Implementation patterns and examples for OwnedByOrganization, Auditable, and Evidenceable concerns including required associations and migrations.
  • Best practices for state-as-separate-records, callback ordering, polymorphic associations, Pundit integration, performance considerations, and testing concerns in isolation with Minitest shared examples.
  • Migration and database recommendations (foreign keys, indexes, counter caches) and integration notes for Current.user/Current.organization usage.

Quick Start

Create a new concern file under app/models/concerns using ActiveSupport::Concern, document the needed migrations and tests, include the concern in the target model, and verify scoping and audit behavior in integration tests.

Frequently Asked Questions about afal-concerns

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

FAQPage Schema
How do I create reusable ActiveSupport::Concerns for Rails model behavior?

ActiveSupport::Concerns let you extract cohesive model logic by defining an included block, class_methods, and instance methods, ensuring consistent behavior composition across multiple Rails models without duplicating code.

What's the best way to implement multi-tenant scoping in Rails models?

Multi-tenant scoping is implemented by extracting an OwnedByOrganization concern that declares required associations and applies default scopes using Current.organization, ensuring all queries are automatically filtered by the current tenant organization.

How do I add audit trails to Rails models using concerns?

Adding audit trails involves creating an Auditable concern that integrates with Current.user and uses ordered callbacks to track model changes, along with required migrations for foreign keys and indexes to store the audit data consistently.

How do I attach polymorphic evidence files to Rails records?

Polymorphic evidence attachments use an Evidenceable concern defining a polymorphic association, requiring specific database migrations for foreign keys and indexes to link diverse record types to shared evidence files efficiently.

Can I test isolated Rails concerns with Minitest shared examples?

Testing isolated Rails concerns with Minitest shared examples is supported by defining reusable test modules that validate concern behavior independently, ensuring scoping, audit trails, and evidence attachments function correctly before model integration.

When should I not use ActiveSupport::Concerns for Rails model logic?

ActiveSupport::Concerns should be avoided when model logic lacks cohesion across multiple classes, creates excessive callback ordering complexity, or degrades query performance through heavy default scopes that obscure direct database interactions.