# How to create multiple applications?

**URL:** <https://www.ruby-forum.com/t/how-to-create-multiple-applications/66598>\
**Category:** Rails\
**Created:** [August 27, 2006, 5:04pm UTC](https://www.ruby-forum.com/t/how-to-create-multiple-applications/66598 "2006-08-27T17:04:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JimL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@JimL](https://www.ruby-forum.com/u/JimL)\
**Post date:** [August 27, 2006, 5:04pm UTC](https://www.ruby-forum.com/t/how-to-create-multiple-applications/66598/1 "2006-08-27T17:04:43Z")

</div>

Hi,  
I’m just starting with Ruby/Rails, and working through OnLamp’s  
“Rolling with etc”. I got the cookbook app working OK, but now I want  
to create a little project of my own.

I now realise that the url used to access a controller (say  
“HelloWorld” doesn’t include the “cookbook” level. So is there only one  
set of controllers for a given Rails server or what? (I’m using  
Webrick on XP)

Thanks,  
Jim

---

<div class="post-metadata">

**Author:** ![JimL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@JimL](https://www.ruby-forum.com/u/JimL)\
**Post date:** [August 27, 2006, 9:55pm UTC](https://www.ruby-forum.com/t/how-to-create-multiple-applications/66598/2 "2006-08-27T21:55:02Z")

</div>

JimL wrote:

> I’m just starting with Ruby/Rails, and working through OnLamp’s  
> “Rolling with etc”. I got the cookbook app working OK, but now I want  
> to create a little project of my own.
> 
> I now realise that the url used to access a controller (say  
> “HelloWorld” doesn’t include the “cookbook” level. So is there only one  
> set of controllers for a given Rails server or what? (I’m using  
> Webrick on XP)

There are several ways to run multiple Rails apps. Which way you go  
depends on a number of factors.

1. Different ports. You can use -p to tell webrick (or  
mongrel) to run on a port other than the default 3000. This is the  
easiest way to go during development.

2. Mapping directories. You can use Apache (or your favorite  
alternative) to map a /cookbook/ directory to one Rails app and  
/checkbook/ to another. I think mongrel is a bit touchy doing this,  
though it may have been fixed in the latest release. This isn’t a good  
solution during development, since it requires all your apps to run  
behind Apache and that’s annoying to work with.

3. Mapping subdomains. You can use Apache (etc) to map a subdomain to a  
Rails app. For example, [cookbook.domain.com](http://cookbook.domain.com) is one app, and  
[checkbook.domain.com](http://checkbook.domain.com) is another. Again, not a great setup for  
development but I’ve had good results deploying this way for production.

If all you’re doing is playing around with Rails, go with (1) for now.  
When you’re ready to deploy things, you’ll need to explore options like  
(2) and (3).

–  
Josh S.  
[http://blog.hasmanythrough.com](http://blog.hasmanythrough.com)

---

<div class="post-metadata">

**Author:** ![JimL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@JimL](https://www.ruby-forum.com/u/JimL)\
**Post date:** [August 28, 2006, 12:01am UTC](https://www.ruby-forum.com/t/how-to-create-multiple-applications/66598/3 "2006-08-28T00:01:21Z")

</div>

On Sun, Aug 27, 2006 at 07:55:25AM -0700, JimL wrote:

> I now realise that the url used to access a controller (say  
> “HelloWorld” doesn’t include the “cookbook” level. So is there only one  
> set of controllers for a given Rails server or what? (I’m using  
> Webrick on XP)

There is only one set of controllers per application. When running the  
default webrick-backed webserver, you can only run one Rails  
application,  
but that is a limitation of the dinky-toy webserver, not Rails itself.

- Matt

–  
“I have a cat, so I know that when she digs her very sharp claws into my  
chest or stomach it’s really a sign of affection, but I don’t see any  
reason  
for programming languages to show affection with pain.”  
– Erik Naggum, comp.lang.lisp

---

<div class="post-metadata">

**Author:** ![JimL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@JimL](https://www.ruby-forum.com/u/JimL)\
**Post date:** [August 28, 2006, 4:53pm UTC](https://www.ruby-forum.com/t/how-to-create-multiple-applications/66598/4 "2006-08-28T16:53:06Z")

</div>

Thanks for your replies, both  
J

---

<div class="post-metadata">

**Author:** ![JimL](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@JimL](https://www.ruby-forum.com/u/JimL)\
**Post date:** [January 31, 2007, 12:48am UTC](https://www.ruby-forum.com/t/how-to-create-multiple-applications/66598/5 "2007-01-31T00:48:12Z")

</div>

Josh:  
I have a similar situation. I hosted my cookbook and photo album on  
a web server using apache. I tested both applications using webbrick  
and different ports and both work fine. I converted them to fcgi and  
used the root domain linked to index.html in the ~/public\_html  
directory and pointes to the applications hosted in the root directory  
~/cookbook/public and ~/photos/public.

The Robins Nest FX

| ![cookbook](https://www.ruby-forum.com/cookbook/images/marythumb.jpg "Marys Cookbook Online") |  

The Robins Family Cookbook

 |
| ![photos]( "Photo Album") | 

The Robins Family Photo Album

 |

The only problem I have, so far, is that clicking on a link in the  
photo album list rdirects back to the root url. (http://  
[therobinsnestfx.com/?album\_id=74](http://therobinsnestfx.com/?album_id=74)). My ~/public\_html/.htaccess looks  
like this:

Options +FollowSymLinks +ExecCGI  
RewriteEngine On  
Redirect [http://therobinsnestfx.com/](http://therobinsnestfx.com/) [http://therobinsnestfx.com/](http://therobinsnestfx.com/)  
photos/  
RewriteRule ^([^.]+[^/])$ http://%{HTTP\_HOST}/$1/ [R=301,L]  
RewriteCond %{HTTP\_HOST} !therobinsnestfx.com$  
RewriteCond %{HTTP\_HOST} !^70.47.57.170  
RewriteCond %{HTTP\_HOST} (www.)?([^.]+.)(._)$  
RewriteRule ^(._)$ http://%3/$1 [L]

I assume the problem is something in the photos .htaccess or routes

The .htaccess in photos is:

# General Apache options

AddHandler fastcgi-script .fcgi  
AddHandler cgi-script .cgi  
Options +FollowSymLinks +ExecCGI  
RewriteEngine On  
RewriteBase /photos

RewriteRule ^$ photos/ [QSA]  
RewriteRule ^([^.]+)$ $1.html [QSA]  
RewriteCond %{REQUEST\_FILENAME} !-f  
#RewriteRule ^(._)$ dispatch.cgi [QSA,L]  
RewriteRule ^(._)$ dispatch.fcgi [QSA,L]

ErrorDocument 500 “

## Application error
Rails application failed  
to start properly”

Any cluse on how to straighten this out?

Thanks  
Jim

On Aug 27 2006, 7:55 pm, Josh S. \<rails-mailing-l…@andreas-
