I made some apps with rails.
I'm getting used to class, but I don't really understand the module.
There seems to be no difference from the class, but what is the difference and how do you use it differently?
Create a module when you want to synthesize methods that span multiple classes instead of inheritance.
class=>can be instantiated.inheritable.
module=>Unable to instantiate.Namespace and method container.The method can be mixed in.
Rails often use ActiveSupport::Concern to create modules.
[Rails] ActiveSupport::Concern Reasons for Existence - Qiita
For example, if you implement only the upload function as concern on the controller that uploads files, it's a versatile application.
© 2024 OneMinuteCode. All rights reserved.