I'm reasonably a new comer to Ruby on Rails so I don't know how you can implement this. My understanding is the fact that rails isn't made with multiple databases in your mind, although I possibly could use establish_connection etc to really make it work.

My primary issue is:

I've an SaaS/application that will assist several companies. Each business may have several database tables for example: customers, comments, messages, transfers, navigation history, logs etc. It appears I've 3 options:

1: Store everybody's data in a single database with every object belonging_to some business or simply marking something similar to a businessID/title. Make use of this tag to fetch the right data and be worried about scaling/performance later as my application develops. (Would I need to bother about this beautiful in early stages?)

2: One database per Business. You don't need to store associations, and db queries perform consistently through the application's existence (possibly bad assumption here).

3: Have separate cases of my application each running some quantity of companies (unsure this really is worthwhile).

What I've come across utilized in other frameworks/companies is simply (2) multiple dbs. I'm also really interested is what's the best practice in rails too. I understand several programs have this same issue and hearing how it has been solved can help.

Any assistance is much appreciated. Many thanks.

Env.
Ruby 1.9.2
Rails 3.1
Production:Heroku or EY (still determining, now running on heroku)

Based on this page, You'd have to apply some metaprogramming for multiple databases.

Why don't you build your deployment script to deploy to various sites with various database configurations? One branch per business? May need more maintenance, but enables for per-business code if you want it.