Skip to content

Instantly share code, notes, and snippets.

@ncr
Created July 15, 2009 18:15
Show Gist options
  • Save ncr/147870 to your computer and use it in GitHub Desktop.
Save ncr/147870 to your computer and use it in GitHub Desktop.
It can be confusing, let me explain it:
When the removed feature was back and I wanted to invoke rake tasks that don't load :environment task (so no masochism) I was getting errors because those tasks treated my slave db as the only db. database.yml looked something like this:
production:
database: slave
master_database:
database: master
So I thought I will try to add slave_database and change the production db to master like this:
production:
database: master
slave_database:
database: slave
master_database:
database: master
I wanted this config so it's backward compatible with those tasks that don't know about masochism.
The problem was the removed feature: when slave_database: key is present then in effect the ActiveRecord::Base connection is not hijacked with proxy (ActiveReload::SlaveDatabase gets hijacked instead). Because of that the most default usage (where people want all AR::Base subclasses hijacked with conn proxy AND basic rake tasks functional) was impossible.
It's of course still possible to configure masochism in the previous way:
ActiveReload::ConnectionProxy.setup_for ActiveReload::MasterDatabase, ActiveReload::SlaveDatabase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment