Rails concerns

Oct 29, 2016

By default Rails 4 and higher applications come with concerns in app/models/concerns/* and app/controllers/concerns/*. It can be a useful place to put code that needs to be shared across classes. It is also a way to implement multiple inheritance.

There is no reason we need to limit this approach to only models and controllers. Perhaps there is common logic that we want to include in several jobs. We could place it in ApplicationJob from which other Job classes inherit. Or we could put it in app/jobs/concerns/shared_job.job and include that module in the specific jobs as needed.