How to create multiple applications?

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

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 is one app, and
    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

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

Thanks for your replies, both
J

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

The Robins Family Cookbook

photos

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). My ~/public_html/.htaccess looks
like this:

Options +FollowSymLinks +ExecCGI
RewriteEngine On
Redirect 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-