Rails controller inheritance against problems and mixes

I have many similar resources in my Rails application, and I'm currently DRY'd code using controller inheritance. I see that in the controller folder there is a directory called "problems" where I could write similar problems (for example, archiving, activation / deactivation, etc.). Perhaps I will also write mixtins.

Is there a preferred DRY approach for controller code? Is there a drawback to using inheritance, or are there any advantages using other methods?

+2
source share
1 answer

Is there a preferred DRY approach for controller code?

In my experience, it depends on what you want to do. I used problems only for simple controller-independent methods like before_action or something

I would use inheritance if your controller methods can rely on a superclass or something like that. My experience so far has led me to use inherited_resources - a DRY way to create controller inheritance

+1
source

All Articles