Module: SlavePools::ActiveRecordExtensions::ClassMethods

Defined in:
lib/slave_pools/active_record_extensions.rb

Instance Method Summary collapse

Instance Method Details

#connection_proxyObject



12
13
14
# File 'lib/slave_pools/active_record_extensions.rb', line 12

def connection_proxy
  SlavePools.proxy
end

#transaction(options = {}, &block) ⇒ Object

Make sure transactions run on master Even if they’re initiated from ActiveRecord::Base (which doesn’t have our hijack).



19
20
21
22
23
24
25
# File 'lib/slave_pools/active_record_extensions.rb', line 19

def transaction(options = {}, &block)
  if self.connection.kind_of?(ConnectionProxy)
    super
  else
    self.connection_proxy.with_master { super }
  end
end