Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle nested ActiveRecord transactions

  • Loading branch information...
commit 25f861638f987dd6a4b767f93538013b1e34f7bf 1 parent 06763bd
@agraefe agraefe authored committed
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/active_reload/connection_proxy.rb
View
8 lib/active_reload/connection_proxy.rb
@@ -51,11 +51,11 @@ def self.setup_for(master, slave = nil)
slave.connection_proxy = new(master, slave)
end
- def with_master
+ def with_master(to_slave = true)
set_to_master!
yield
ensure
- set_to_slave!
+ set_to_slave! if to_slave
end
def set_to_master!
@@ -77,7 +77,9 @@ def set_to_slave!
:dump_schema_information, :execute, :to => :master
def transaction(start_db_transaction = true, &block)
- with_master { master.transaction(start_db_transaction, &block) }
+ with_master(start_db_transaction) do
+ master.transaction(start_db_transaction, &block)
+ end
end
def method_missing(method, *args, &block)
Please sign in to comment.
Something went wrong with that request. Please try again.