Let’s say that one has a set of controller actions that he plans to
deploy on a collection of different web sites. For the most part, any
particular action on any given web site in the collection is the same
as the corresponding action on any other web site in the collection.
However, there can be minor customizing tweaks to various actions on a
site by site basis. So, across web sites, corresponding controller
actions are similar but not identical.
It would be nice to have the base (common) code for the actions in a
superclass of the controller. That way the base code could be kept
pristine and identical across all web sites. The minor customizing
tweaks could be implemented as overriding code in the controller.
That makes the tweaks much more prominent. In addition, the big
advantage is that if the base code is updated and the updates don’t
affect the tweaks, updates to the base code are simply drop-in
replacements which don’t require any customization.
The base code could be put in the application controller; but, then it
would inherit down to all controllers. A separate class for each
controller inserted between the application controller and the
particular controller involved is what seems to be needed. My
question is: Is that the way to do it; or, is there a better way?
I’m concerned about breaking the class chain setup by Rails. Maybe
it’s no big deal; but, I’d like to know that for sure.
Thanks for any input.