Skip to content

Commit

Permalink
added docs how to use with Phusion Passenger
Browse files Browse the repository at this point in the history
  • Loading branch information
schoefmann committed Apr 21, 2009
1 parent bf01a3e commit 2ac8233
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions README.rdoc
Expand Up @@ -25,10 +25,7 @@ master database.

=== Caveats

* works with activerecord 2.1 and 2.2
* when using Passenger or lightspeed you will probably need to introduce a
before_filter which checks if the proxy is setup (see the discussion in the
masochism readme: http://github.com/technoweenie/masochism)
* works only with activerecord 2.1, 2.2 and 2.3

=== Install

Expand Down Expand Up @@ -87,6 +84,28 @@ for master and slave connections. This can help you finding (some of the) issues
your application might have with a replicated database setup without actually having
one on your development machine.

=== Using with Phusion Passenger

With Passengers smart spawning method, child processes forked by the ApplicationSpawner
won't have the connection proxy set up properly.

To make it work, add this to your <tt>environment.rb</tt> or an initializer script
(e.g. <tt>config/initializers/connection_proxy.rb</tt>):

if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
if forked
# ... set MultiDb configuration options, if any ...
MultiDb::ConnectionProxy.setup!
end
end
else # not using passenger (e.g. development/testing)
# ... set MultiDb configuration options, if any ...
MultiDb::ConnectionProxy.setup!
end

Thanks to Nathan Esquenazi for testing this.

=== Forcing the master for certain actions

Just add this to your controller:
Expand Down

0 comments on commit 2ac8233

Please sign in to comment.