I am using single table inheritance in StudentHours and TeacherHours, which have a parent Hours.
The model code is mostly in hour.rb, and very little in student_hour.rb and teacher_hour.rb
Now I have realized that most of the controller code is duplicate as well, so I've created a hours_controller to be the parent of students_controller and teachers_controller. Because the hours_controller instantiates model objects such as TeacherHours.new I've created a accessor in the child classes such as:
def MyModel
@mymodel = "TeacherHours"
end
... then the hours_controller simply calls MyModel.new
Occasionally there are other models that are referenced and sometimes I even call 'render' on a view so I made accessors in the child classes for those too.
I can't find example of others doing this. So, is this bad for any reason, or is there a better way?