Sha256: 72f410d04f4e0b33640eff3c7e0babd7a19a4feedcf6a654d0b32587089490ac
Contents?: true
Size: 654 Bytes
Versions: 1
Compression:
Stored size: 654 Bytes
Contents
module ActiveRecordSlave module InstanceMethods # Database Adapter method #select is called for every select call # Replace #select with one that calls the slave connection instead def select_with_slave_reader(sql, name = nil, *args) # Only read from slave when not in a transaction and when this is not already the slave connection if (open_transactions == 0) && !ActiveRecordSlave.read_from_master? ActiveRecordSlave.read_from_master do Slave.connection.select(sql, "Slave: #{name || 'SQL'}", *args) end else select_without_slave_reader(sql, name, *args) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_record_slave-1.1.0 | lib/active_record_slave/instance_methods.rb |