Getting a model to connect to a different DB


#1

Hi guys,

I’m still finding my feet in rails and I would be really grateful if you
could help me with this problem:

I need to use 2 databases for my application; one for user details and
one for everything else. So basically what I think I need to do is set
the database to the general one as default and then tell the User model
specifically to connect to the user DB.

I have added an extra DB definition to the databases.yml file but I’m
not sure how to tell the User model to use this database. How can I do
this? There are instuctions on the rails wiki
(http://wiki.rubyonrails.com/rails/pages/HowtoUseMultipleDatabases) but
they don’t seem to work ;(

Thanks!

Sirdavidoff


#2

Stupid me, turns out there was an article on the wiki about this:

http://wiki.rubyonrails.com/rails/pages/HowtoUseMultipleDatabasesOnePerTable

Although why there have to be extra articles saying that another article
is wrong instead of just fixing the first article is beyond me :wink: