Ruby on Rails
HowtoUseSharedControllers

Derek Sivers—that CD Baby guy—has derived a slick shared controller system to further push the DRY boundries:

http://dereksivers.com/rails-shared-controller.html

Following Derek’s code, you can also change mymodel in the parent controller so you don’t need to explicitly declare the model class to use.


 def mymodel
    Object.const_get controller_name.capitalize
  end

Then your controllers just become:

class BioController < WizardController; end
class CalendarController < WizardController; end



Under rails 1.0 I find I have to use

 def mymodel
    Object.const_get controller_name.camelcase.singularize
  end


But then I am rails novice and thus the above may be doing something simple the hard way.