For legacy reasons, my model's tables are stored in two different databases on the same MySQL server. At first I just used establish_connection
to specify the second database on the models that used it. However, when I established a has_many :through
connection between two models in different databases, it blew up because MySQL cannot JOIN across two different servers. Then I noticed on the interwebs that I could use set_table_name 'other_database.foos'
instead of using establish_connection
.
This mostly works, but table_exists?
always returns false even when the table does exist, and a couple of the plugins I'm using use that function extensively.
Is this a bug in table_exists?
, or am I misusing set_table_name
? Is there another way of doing what I'm trying to do?