One thing that took me a while to wrap my head around is concerns. Part of that is just that I hadn’t really used them before and they’re more of a Ruby (and Rails) thing that with other languages. At the same time, they’re SUPER powerful and helpful. It feels like people could see the power of Rails better if they understood Rails and concerns.
There are a set of things that could help with this:
- Putting a concern focused guide together on guides.rubyonrails.org. There are a number of places where concerns are mentioned but they don’t really explain why you’d use a concern, how to use them, how concerns are already used in Rails and which concerns (and what they do) are available in Rails already for use by developers
- Have a generator for concerns. Concerns, like other parts of a rails application, belong in a particular place in the file hierarchy
app/*/concerns, should have a particular name and structure and should be in the
concernssubdirectory of the part of the application they relate to, i.e. a controller concern should be in