Permalink
Browse files

added some documentation

  • Loading branch information...
1 parent bc014a6 commit 4aaa0298207ec5042f66afcc68ccb69ae4e5b48f @abloom abloom committed Oct 1, 2008
Showing with 10 additions and 1 deletion.
  1. +8 −0 README
  2. +2 −1 lib/active_reload/master_filter.rb
View
8 README
@@ -74,3 +74,11 @@ Setting up your own proxies:
# Sets up MyMaster's connection as the master database connection for User.
ActiveReload::ConnectionProxy.setup_for MyMaster, User
+Using the MasterFilter class is quite simple. If you have any actions you know require
+the Master DB for both reads and writes simply do the following:
+
+class RandomController < ApplicationController
+ around_filter MasterFilter, :only => [:show, :edit, :update]
+
+ ...
+end
@@ -1,9 +1,10 @@
module ActiveReload
+ # MasterFilter should be used as an around filter in your controllers that require certain actions to use the Master DB for reads as well as writes
class MasterFilter
def self.filter(controller, &block)
proxy = ActiveRecord::Base.active_connections['ActiveRecord::Base']
- if proxy and proxy.respond_to? :with_master
+ if proxy and proxy.respond_to?(:with_master)
proxy.with_master(&block)
else
yield block

0 comments on commit 4aaa029

Please sign in to comment.