What is the best way to do per-user database connections in Rails?
I realize this is a poor Rails design practice, but we’re gradually replacing an existing web application that uses one database per user. A complete redesign/rewrite is not feasible.
Put something like this in your application controller. I’m using the subdomain plus ‘_clientdb’ to pick the name of the database. I have all the databases using the same username and password, so I can grab that from the db config file.
Hope this helps!