4 Rails apps using the same table. How to streamline?

Hi,

I have 4 apps using similar User tables(3 open source projects and one
in-house app). I’m trying to merge into one shared database User table
(external to all 4 apps).


I’m using the following code in the User model to switch to the shared
database:

class User < ActiveRecord::Base

GSL, 03/18/09 - Add reference to external ua database.

User.establish_connection (
:adapter => “mysql”,
:host => “example.corp.example.com”,
:username => “root”,
:password => “?”,
:database => “ua_production”
)

Then, I have to switch the other models back:
class Attachment < ActiveRecord::Base

GSL, 03/18/09 - Add reference to external ua database.

Attachment.establish_connection (
:adapter => “mysql”,
:host => “example.corp.example.com”,
:username => “root”,
:password => “?”,
:database => “redmine”
)


I added the above to all the other models in my Redmine app.

So, now the views that are trying to do a SQL JOIN are bombing.

Is there an easier way?

Thanks in advance.