How do I globally switch the database connection?


I’m trying to switch from one database to another. Current, I have

def set_database
@client_id = ‘production’
config = YAML.load(, ‘config/
database.yml’)) )
db = config[@client_id]
raise ‘Invalid client id’ if db.nil?
ActiveRecord::Base.connection =

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs