what is difference between using concerns vs modules in rails?

Ramkumar picture Ramkumar · Dec 16, 2015 · Viewed 12k times · Source

Just now I started to using Concerns in rails, but i have doubt why we go for concerns, because we can achieve same thing on module & mixing concept. So please any one tell about shat is the use of concerns instead of using module.

Answer

zinovyev picture zinovyev · Oct 11, 2017

It's well described here: http://api.rubyonrails.org/classes/ActiveSupport/Concern.html

In short:

  • Concerns allow you to use #included and #class_methods instead of self.included hook with additional module ClassMethods creation;

  • Concerns give you a better dependency resolution for modules included in each other;