Domain specific controllers


I am investigating having a multi-domain rails app, where I have a
central “core” that works across many domains and is supplemented by
domain specific functionality.

I have looked into adding routing functions to Rails and have
experimented with adding host, domain and subdomain to the request using
info gleaned fro Jamis B.'s blog.

What I want to try and achieve next is to write a plugin that extends
the rails directory hierarchy so I can do something like the below:

| +mydomain1controller.rb

The idea is that accessing the site using mydomain1 would use the
application.rb and mydomain1controller.rb from the mydomain1
subdirectory; it would use mygeneralcontroller.rb from the controllers
directory. Accessing the site using mydomain2 would use application.rb
and mygeneralcontroller.rb from the controllers directory. It would use
mycontroller.rb and mydomain2controller.rb from the mydomain2
subdirectory. Accessing the site using any other domain would just use
the files in the controllers directory.

A similar paradigm would exist in the other subdirectories of “app”.

How would I do this? Is there a mechanism already there for this? Any