oop-concerns-and-mixins

Installation
SKILL.md

Concerns & Mixins

What it is

A Concern is a module (backed by ActiveSupport::Concern) that encapsulates a reusable chunk of model or controller behavior — validations, scopes, callbacks, instance methods — and mixes it in. Concerns are the Rails-idiomatic alternative to deep inheritance chains.

Concerns are composition, not extraction. Don't reach for them to shrink a fat model; reach for them when the same behavior genuinely belongs to multiple models.

Would a fat model do?

Keep behavior on the model until:

  • 2+ models share identical validations, scopes, or instance methods
  • The shared behavior forms a coherent capability (e.g. "can be published", "can be archived")
  • The module name reads as an adjective describing what the model is able to do: Publishable, Archivable, Taggable, Searchable

If only one model uses it, it's not a concern — it's just a private section of the model.

When NOT to

Installs
2
First Seen
May 8, 2026
oop-concerns-and-mixins — gierd-inc/dev-skills