Forum: Ruby on Rails Multiple Sites, One Rails App

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3fdda7e032a5619199486d05b506ced4?d=identicon&s=25 Brad Daily (bdaily)
on 2006-01-04 02:35
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?
6dab365a82517fb694650a57ee88e4a4?d=identicon&s=25 joey__ (Guest)
on 2006-01-04 08:56
Brad Daily 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.
3fdda7e032a5619199486d05b506ced4?d=identicon&s=25 Brad Daily (bdaily)
on 2006-01-04 21:50
Found a good solution (I think) :)

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....
Fd3a01306acbc090a33ed3fdf1882c53?d=identicon&s=25 Truong-an (Guest)
on 2006-09-27 22:16
Hi Brad, did you ever figure out a way to make this work locally?

Brad Daily wrote:
> Found a good solution (I think) :)
>
> 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....
0f23274e975611727e4ad46d745d298e?d=identicon&s=25 Bill (Guest)
on 2006-09-28 00:40
There is a routing request plugin that should work here.  Make sure to
check it's read me file.

Bill
This topic is locked and can not be replied to.