Module: ActiveRecordShards::DefaultReplicaPatches::Rails52RelationPatches

Defined in:
lib/active_record_shards/default_replica_patches.rb

Instance Method Summary collapse

Instance Method Details

#connectionObject



123
124
125
126
127
128
129
130
131
132
# File 'lib/active_record_shards/default_replica_patches.rb', line 123

def connection
  return super if Thread.current[:_active_record_shards_in_migration]
  return super if Thread.current[:_active_record_shards_in_tx]

  if @klass.on_replica_by_default?
    @klass.on_replica.connection
  else
    super
  end
end