set_table_name on the fly

Hi. I have a model that connects to a database, does something, connects
to a different database, does something, and so on.

The switching of the databases appears to work, as calling:

MyModel.connection.instance_eval { @config[:database] }

Yields the correct database.

After changing databases I also call:


However, upon issuing a query:


I receive an error similar to:

Unknown column 'old_table_name.column' in 'where clause'...

Any ideas?