title: Controller inheritance in Ruby on Rails -- model and controller access in parent class
body: <p>I am using single table inheritance in StudentHours and TeacherHours, which have a parent Hours.</p>
  
  <p>The model code is mostly in hour.rb, and very little in student_hour.rb and teacher_hour.rb</p>
  
  <p>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:</p>
  
  <pre><code>def MyModel
   @mymodel = "TeacherHours"
  end
  </code></pre>
  
  <p>... then the hours_controller simply calls MyModel.new</p>
  
  <p>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. </p>
  
  <p>I can't find example of others doing this. So, is this bad for any reason, or is there a better way?</p>