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.