Multiple rails apps to appear as one app


#1

Hello everyone,

I have a problem concerning two rails apps, which I can’t seem to solve.
I already tried the Ruby On Rails IRC channel. I also started a thread
at the Site5 forums:

http://forums.site5.com/showthread.php?t=6682

As is described in
http://wiki.rubyonrails.com/rails/pages/HowtoDeployMoreThanOneRailsAppOnOneMachine
, I would like two separate Rails applications to appear to the visitor
as if they were one combined application.

I am in the process of moving my website over to a Site5 hosted domain (
http://jozilla.be/). I wanted to redesign my homepage with Rails, while
also running a Typo blog.

Ok, let’s get to the point. I have a two directories in my homedir,
namely “typo” and “homepage”. Both are Rails applications. Then I have a
“public_html” directory, which has two symlinks “homepage” and “blog”,
which point respectively to “~/homepage/public” and “~/typo/public”.

Both these applications work fine. I can visit my homepage by going to
http://jozilla.be/homepage/ and I can go to my blog by typing in
http://jozilla.be/blog/ .

But what I really want is http://jozilla.be/ serving up the homepage
Rails app, while http://jozilla.be/blog/ goes to the Typo blog. Ok,
you’ll say, just use a RewriteRule to rewrite http://jozilla.be/ to
http://jozilla.be/homepage/ (Site5 is running Apache btw).

But that’s not what I want. I never even want to see “homepage” in the
URL. So http://jozilla.be/ should serve http://jozilla.be/homepage/,
http://jozilla.be/links should serve http://jozilla.be/homepage/links,
etc without ever redirecting to that particular URL.

Well, you’ll say, even that is solvable by using RewriteRule’s. Indeed
it is. But Rails still thinks it’s living in the homepage subdirectory.
So if I click on a link such as <%= link_to “Links”, :controller =>
“links” %>, the visitor is still pointed at
http://jozilla.be/homepage/links instead of http://jozilla.be/links!

I thought maybe Apache’s Alias directive could solve this (“Alias /blog
/path/to/blog” and “Alias / /path/to/homepage”). However aliases can
only be defined in the server config, which is out of my control.

Is there a way to handle my problem using Routing?

The only way I can think of to make it work is having two separate
document roots for the application, such as http://jozilla.be/ having
“homepage” as it’s document root, and http://blog.jozilla.be/ having
“blog” as it’s document root. But that’s not really one integrated
website anymore.

Maybe I am still in the PHP mindset (a website is made of a collection
of script files, which can be placed anywhere), but it looks like a
shortcoming of rails if I can’t present two separate applications as one
website to the visitor.

I hope you guys can help me out! Thanks in advance!

Best regards,


Jo Vermeulen


#2

Jo Vermeulen wrote:

Hello everyone,

I have a problem concerning two rails apps, which I can’t seem to solve.
I already tried the Ruby On Rails IRC channel. I also started a thread
at the Site5 forums:

Well apparantly this has been an open issue for a while now:

http://wiki.rubyonrails.com/rails/pages/HowToMergeTwoOrMoreRailsApplications

I guess that means nobody really knows how to fix it :frowning:

Best regards,

– Jo Vermeulen


#3

On 12/14/05, Jo Vermeulen removed_email_address@domain.invalid wrote:

removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

You can set the relative url_root…

ActionController::AbstractRequest.relative_url_root = “/my_app_root”

Does that help?
pth


#4

Patrick H. wrote:

On 12/14/05, Jo Vermeulen removed_email_address@domain.invalid wrote:

removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

You can set the relative url_root…

ActionController::AbstractRequest.relative_url_root = “/my_app_root”

Does that help?
pth

No I already tried that.

Well in fact, maybe what I’m doing isn’t quite clean. So I have fixed it
by creating a separate document root for my blog. My homepage is now
located at the main domain, and my blog at a blog subdomain.

Thanks for your answer!

– Jo