Topic: Deploying multiple instances of a Rails Application (independent data)

Hi,

Firstly, Happy New Year everyone.

I'm new to Rails, so please tolerate any incorrect use of terminology...

I have developed a simple Rails application, backed by a MySQL database.

I would now like to deploy this application to multiple, independent groups of users (i.e. it is a club application, and I would like to deploy it to a number of completely independent clubs).

I would like to use the same Rails Application code as much as possible, and just have a separate instance of the database for each club.

I assume I can use a different port for each Rails server to steer users to the correct group.

I'd read that there are test and production modes, is it possible to have multiple instances of production modes, e.g. club1, club2, all sharing the same code, with unique databases?

My questions are how to support multiple separate database instances, and also how best to route to these?

Any advice on how to go about this much appreciated.

Re: Deploying multiple instances of a Rails Application (independent data)

You can have any number of "environments" you would like. It just involves a few steps:

1. Create an entry in database.yml. You can call this whatever you want...just follow what the development, test, and production values use. Replace production with the name of your instance.
2. Add an environment file. This is located within config/environments/whatever_env.rb. Make this filename mirror what you called the entry in the database.yml file.
3. When starting your server, you need to indicate the environment..there are a few ways to do this.
    1. Webrick: rails server -e whatever_env (or script/server -e whatever_env)
    2. Passenger: setup RailsEnv whatever_env in your vhost file. (Depending on versions, you may have to use RackEnv)

4.(Optional). You can utilize capistrano-ext gem to help with deployment handling of multiple environments.

For your last question..you will probably need some type of front end application that is handling which app to direct people to, depending on login, or just give them the specific url for that app.

Hope this helps.

Last edited by freezzo (2011-01-03 12:50:17)

Re: Deploying multiple instances of a Rails Application (independent data)

Thanks freezzo, you've confirmed I can just add another environment (test, production, ...) so I'll pursue that route with a bit more confidence ;-)

Your reply is very much appreciated.