I have four controllers: one for the store front and three for the
store admin. In each controller I have copied and pasted exactly the
same code. It is a method called redirect_to() to override Action
Controller’s redirect_to(). Copy and paste is bad. I can think of two
options but I don’t know how Rails will feel about them.
Option 1: Can I create an intermediate controller class like the
following? If so, are their pit falls to this method?
class AdminController < ApplicationController
class ProductController < AdminController
Option 2: I could create a flie in lib/ which contains the
redirect_to() method and then mix it into each controller. This option
doesn’t feel as good for some reason. Also I don’t know what code
would need to be in my controller file to do this.