Go back to the blog

AMA: Why should I use Rails concerns?

Imagine that you want to have some objects that are soft deleted, some clean-up provided data, and some return calculated properties like total price with tax, etc. They share identical functionality, and sometimes it's easier to have the specific logic built-in — for that we have concerns!

Without concerns, you have to copy and synchronize the code between objects sharing similar functionality, but with concerns, you just include the concern and everything is synced.

Same with encapsulation — you just edit everything in one place and can still override in the model itself as needed!

Read more articles like this one:

Code Architecture 5 Ruby on Rails 8