Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Deployment Question
4 Posts
Deployment Question

I'm new to Rails, and currently working on a pretty big Rails SaaS product. It has 30 or so Models and 15 or so Controllers. I'm wondering how I'm going to deploy this. Currently, the product is based off a single implementation...meaning, that for every customer I have, there will be a separate implementation and separate database(not sure if that makes any sense).

To put it another way...in .NET (I'm a .NET developer), for every customer, I would have a separate virtual directory. The application will sit in that VD and the configurations will point to their own database in SQL Server.

For my Rails app, I would like to have each customer have their own MySQL database, and the database.yml file will point to the specific target database. How would you separate each instance of the application for each customer? Is it even possible with Rails?

You can use "establish_connection" in your model to connect to different databases depending on the each customer.

What I have done in the past is to have one deployed application per customer; using Capistrano and its multi-stage extension I would create one deploy file for each new customer.

On another note, I recall DHH being somewhat against the "one database per deploy" schema, arguing it could turn into a maintenance nightmare. He seemed to favor the scoped approach -- where each customer would map to, say, an account, and everything could belong to that account (foreign key).

Hello, you can use one capistrano deployment by user, but if you have a lot of user it will be quickly difficult to maintain all these instances. Why don't you manage one database, one installation of you code and then program some security to prevent one user from accessing the information of others.


4 Posts
Login to add your message