rails-concern

Create Rails concerns with ActiveSupport::Concern using a test-driven RSpec workflow.

Updated Mar 19, 2026
One-click install
npx skills add https://github.com/reckerswartz/resume_builder --skill rails-concern-reckerswartz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-concern
Source: https://github.com/reckerswartz/resume_builder/tree/main/.windsurf/skills/rails-concern
Command: npx skills add https://github.com/reckerswartz/resume_builder --skill rails-concern-reckerswartz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Creates Rails concerns for shared behavior across models or controllers with a test-driven development approach. It helps DRY up code by extracting reusable modules and reducing duplication in models and controllers.

Core Features & Use Cases

  • Reusable concerns built with ActiveSupport::Concern, including included blocks, class_methods, and instance methods.
  • Test-first workflow with RSpec to drive design and ensure behavior remains correct.
  • Cross-cutting patterns such as shared validations, scopes, callbacks, and controller helpers.

Quick Start

Write a failing spec for the concern, then implement the concern and run tests to verify it.

Frequently Asked Questions about rails-concern

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

FAQPage Schema
How do I extract shared validations and callbacks in Rails to avoid duplicating model code?

Rails concerns using ActiveSupport::Concern let you extract shared validations, scopes, and callbacks into reusable modules. This DRYs up models and controllers by packaging cross-cutting behavior under app/models/concerns or app/controllers/concerns.

What is the best way to test Rails concerns with RSpec using a test-driven approach?

Testing Rails concerns with RSpec involves writing a failing spec first to drive the module's design. You verify shared behavior like validations and scopes before implementing the concern logic to ensure correct functionality.

Can I use Rails concerns for shared controller methods and helpers?

Yes, Rails concerns can be used for shared controller helpers. You place the module under app/controllers/concerns and use ActiveSupport::Concern to encapsulate shared instance methods and class methods across multiple controllers.

When should I use ActiveSupport::Concern instead of plain Ruby modules in a Rails application?

Use ActiveSupport::Concern instead of plain Ruby modules when you need to handle module dependencies or add class methods automatically. It is the standard Rails approach for concerns to manage shared behavior and avoid dependency conflicts.

Does the Rails concern TDD workflow support both instance methods and class methods?

Yes, the Rails concern TDD workflow supports both instance methods and class methods. ActiveSupport::Concern provides a class_methods block for class-level methods and standard module syntax for instance methods, both verified by RSpec tests.