Skip to content

Commit

Permalink
Merge commit 'jsmecham/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Jul 1, 2008
2 parents 8de9fda + 0b58f45 commit fec38cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions README
@@ -1,13 +1,14 @@
masochism
==============
=========

The masochism plugin provides an easy solution for Ruby on Rails applications to
work in a replicated database environment. Connection proxy sends some database
queries (those in a transaction, update statements, and ActiveRecord::Base#reload)
to a master database, and the rest to the slave database.

The ActiveReload::MasterDatabase model uses a 'master_database' setting in
database.yml to serve as the master database.
The ActiveReload::MasterDatabase model uses a 'master_database' setting that
can either be defined for all of your environments, or for each environment as
a nested declaration:

# config/database.yml
login: &login
Expand All @@ -16,11 +17,24 @@ database.yml to serve as the master database.
port: 5432

production:
database: slave_database_name
database: production_slave_database_name
<<: *login

master_database:
database: master_database_name
database: production_master_database_name
<<: *login

staging:
database: staging_database_name
host: slave-db-pool.local
<<: *login
master_database:
database: staging_database_name
host: master-db-server.local
<<: *login

development: # Does not use masochism
database: development_database_name
<<: *login

To setup:
Expand Down
2 changes: 1 addition & 1 deletion lib/active_reload/connection_proxy.rb
@@ -1,7 +1,7 @@
module ActiveReload
class MasterDatabase < ActiveRecord::Base
self.abstract_class = true
establish_connection :master_database
establish_connection configurations[Rails.env]['master_database'] || :master_database
end

class ConnectionProxy
Expand Down

0 comments on commit fec38cf

Please sign in to comment.