Multiple Sites, One Rails App

Here is the situation: We have one rails app that is built around our
fairly large DB. Since we have many models and logic inside those
models, it makes sense for us to build only one rails app and share it
among several different sites (Public web site, internal data backend,
etc).

The thing I can’t quite get my head around is how to forward requests
(using lighty) from different domains to top level controllers within
the rails app:

Example:

mysite.com → site controller
data.mysite.com → data controller

etc… The productize plugin seems to be overkill, as we aren’t extending
the app or using different DBs for the different domains. Any thoughts?

Brad D. wrote:

Here is the situation: We have one rails app that is built around our
fairly large DB. Since we have many models and logic inside those
models, it makes sense for us to build only one rails app and share it
among several different sites (Public web site, internal data backend,
etc).

The thing I can’t quite get my head around is how to forward requests
(using lighty) from different domains to top level controllers within
the rails app:

Example:

mysite.com → site controller
data.mysite.com → data controller

etc… The productize plugin seems to be overkill, as we aren’t extending
the app or using different DBs for the different domains. Any thoughts?
You could do something like:
before_filter { |c| redirect_to :controller=>
c.request.subdomains.first, :action => ‘index’ }

This is untested by they way,but it should work.

Found a good solution (I think) :slight_smile:

Instead of trying to consolidate into one app, I have kept the three
separate rails apps that we have so far. However, with the two apps that
build off of the main app’s model structure, I have emptied their models
folder. Then, in their environments.rb file, I have added the
following…

config.load_paths += %W( /home/www/data/app/models )

This way, these apps can directly load the models from the main app, but
still retain their individuality. Working great so far, just have to
figure out a way to work with it locally…

Hi Brad, did you ever figure out a way to make this work locally?

Brad D. wrote:

Found a good solution (I think) :slight_smile:

Instead of trying to consolidate into one app, I have kept the three
separate rails apps that we have so far. However, with the two apps that
build off of the main app’s model structure, I have emptied their models
folder. Then, in their environments.rb file, I have added the
following…

config.load_paths += %W( /home/www/data/app/models )

This way, these apps can directly load the models from the main app, but
still retain their individuality. Working great so far, just have to
figure out a way to work with it locally…

There is a routing request plugin that should work here. Make sure to
check it’s read me file.

Bill