Rails application organization

Hello–

New to Ruby. New to Rails. New to web app development, quite honestly.
I
-really- like Rails, though. I asked this on the comp.lang.ruby list
and
they sent me here!

I’m working on a new web app that would allow customers (companies) to
have
multiple logins which access the same database. The question is how to
set
up something like this–

  1. Have one instance of the app and somehow allow it to use different
    databases depending on the user’s login.

  2. Have multiple instances of the app running on virtual servers,
    similar to
    how cPanel sets up accounts for multiple hosts – each host has its own
    directory, MySQL database, and so on. Then, somehow have one “father”
    web
    app administer this higher level of hierarchy.

Any other suggestions? My experience in setting this sort of thing up
is
limited – are there any good examples of this setup that I could pull
from?
Is this sort of thing relatively painless to do in Rails?

For example, it seems that the online store UltraCart does a similar
thing
– each company gets a company code “DEMO” and can have multiple users
with
different access permissions.

Thanks very much for any suggestions!

Cheers,
Jake