Multiple sites per rails install

Hi All,

We are considering using RoR as the framework for our collection of
sites. Everything looks good so far in our evaluation of RoR, except
for one issue. We have 1000+ sites that are all identical except for
their database and a few customer media files. We would like to have
one install of RoR serve all of our sites, rather than creating 1000+
RoR installs.

For some context, currently we are considering running apache2.2 with
mod_proxy_balancer to mongrel, but very open to suggestions. So we
could set up vhosts to proxy the sites to mongrel. Once mongrel
received the request, somehow come up with a rails context that would
connect it to that sites database. Or some such mechanism…

So that is the goal. I have not evaluated all of the possible options
on how this might be done, but two come to mind as I begin my work:

  1. It appears that I can set the rails environment in the
    environment.rb file, and that I can connect that environment name to a
    database in the database.yml file. So could I somehow select the
    environment from the requested url with some fancy lookup code or
    translation (ie. uses database www_test_com) in the
    environment.rb file or a custom environment in the environments
    directory? I am not sure exactly when the environment files are
    executed? Are they only executed once in the “** Starting Rails with
    development environment …” startup step of mongrel.

  2. Can we somehow use Mongrel::Rails::RailsConfigurator::rails method
    and set the environment there based on the requested url? Somehow hook
    into mongrel using -S script or a plugin of some kind?

  3. I sincerely hope someone has a better answer because the above sound
    to me like total hacks, and very unlikely to work.

Thanks for any input in advance. I am completely new to rails and ruby,
so please forgive my ignorance.


James Pellow

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs