💎 Ruby on Rails
Beginner
What is concerns in Rails?
Answer
Concerns are modules in app/models/concerns/ or app/controllers/concerns/ used to extract and share reusable behavior across multiple models or controllers. They use Ruby's module system with ActiveSupport::Concern, which adds DSL for included and class_methods blocks. Example: a Taggable concern could be included in Post and Product models to share tagging logic. Concerns help keep models slim but can sometimes obscure where behavior is defined — use judiciously.