Rails concern
This is part of the code in Launch School 301 course. And in the code below, it shows how to extract the duplicate code in different module to ActiveSupport::Concern
. But there are more than one way to refactor the code. DHH in the signal v. Noise wrote an article to introduce the concerns
:
Different models in your Rails application will often share a set of cross-cutting concerns. In Basecamp, we have almost forty such concerns with names like Trashable, Searchable, Visible, Movable, Taggable.
Ryan Bates of Railscasts wrote an article to talk to people not to use concern. He encourage people to use Service Object
.
Read more...