I am building a Rails 4 app and trying to have separate databases for different models.
For example;
- the Users model will connect to a database at 192.168.1.2
- the Cars model will connect to a database at 192.168.1.3
- the Books model will connect to a database at 192.168.1.4
How can I achieve this? I've been looking all over the place but haven't found exactly what I want... https://devcenter.heroku.com/articles/concurrency-and-database-connections
The DBCharmer Plugin seems to do it with 'switch_connection_to' BUT it seems it switches the whole database connection every time and does not make use of persistent connections...
--> They mention 'establish_connection' but I have not been able to figure out how to use this /:
Thanks for the help!
FYI: This is using Mysql btw but I assume the solution for Sqlite or postgreSQL would work in the same way.
EDIT
I tested 'establish_connection' in my models and this works great. BUT I was hoping there would be a better way since the db migrations don't get routed to the correct database when doing 'rake db:migrate'
Right?
So if this is correct, then I am supposed to manually export DB schema into the other DB?