Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is difference between using concerns vs modules in rails?

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.

like image 665
Ramkumar Avatar asked Aug 31 '25 15:08

Ramkumar


1 Answers

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;

like image 157
zinovyev Avatar answered Sep 08 '25 22:09

zinovyev