Forum: Ruby on Rails Login chooses database

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B22ed587fc21c4d084c5c7b3199de67a?d=identicon&s=25 Rike Hase (rike)
on 2009-03-28 01:15

I just finishes my first RoR application and I'm happy that nearly every
problem I had was solved. But now I need your help. The problem is that
an other organisation wants to use my application as well. The server
will stay the same, but the want to have a seperate database (with the
same structure as the first one). I don't want to copy my
application-files because this would be very unpractible for the further
Unfortunately I have no idea how to realize this. May I put in a
selection field to the loginform, where the user chooses his
organisation? Is it possible that useres of different organisation work
at the same time with the apllication with different databases? Is there
a possibility with the session?
I treasure every hint!

Thanks a lot

503d4414789324e37723b90e13c076c1?d=identicon&s=25 Andrew (Guest)
on 2009-03-28 09:23
(Received via mailing list)
How about using a single Rails app and configuring your apache or
webserver to point two domain names to the same application. Then,
based on the domain in the login request, you can determine how to
authenticate your user.

On your "User" model, would associate each user with a domain (ex.
domain1 or domain2)  which would govern business logic depending on
the user.

On Mar 27, 5:15 pm, Rike Hahn <>
47c3af2d56d44eb1d08a601c837a1262?d=identicon&s=25 alberto (Guest)
on 2009-03-28 20:12
(Received via mailing list)
> I just finishes my first RoR application

Good for you. And now someone else wants to use it, even better!

As to how to do this, one reliable way to do this is to use version
control and capistrano.

version control
If you have not added your code base to a version control repository,
now is the time to do this. Whether you choose to use subversion or
git, setup a server in your environment to keep incremental changes to
your application there. Version control gives you the ability to name
your versions.

once you have your repository, you "deploy" new versions of your
application to any number of servers. In this case, you have two
"users" of your app. So whether the apps are housed on the same
server, or two servers, you use capistrano to write
"recipes" (scripts) to deploy to the target servers.

It is a proven, scalable way of doing what you want. Then, anytime
something changes, as it always happens, you have the choice to apply
your changes to one or both apps, and affect one or the two databases.
Keeps things under control.

Good luck, and congrats again.
B22ed587fc21c4d084c5c7b3199de67a?d=identicon&s=25 Rike Hase (rike)
on 2009-03-29 00:30
Thanks a lot for your good tipps! This means I have to copy the whole
application to f.e. a subdomain? So if 3 other organisations want to use
this application I copy the whole code three times? Ok. So when I have a
new version then capsitrano helps me to update the other apps? Right?
... I think this will be a not trivial job...
I know git a (very) little bit. It seems that I have to go in with this.
:-) So, thank you again - I will try this.
This topic is locked and can not be replied to.