How do I globally switch the database connection?

Hi,

I'm trying to switch from one database to another. Current, I have this:

def set_database     @client_id = 'production'     config = YAML.load( File.open(File.join(RAILS_ROOT, 'config/ database.yml')) )     db = config[@client_id]     raise 'Invalid client id' if db.nil?     ActiveRecord::Base.connection = ActiveRecord::Base.establish_connection(db) end

Obviously, that's not working 'cause I'm asking for help! :slight_smile: No errors being thrown, but database is not getting switched.