Module: ActiveRecordShards::DefaultReplicaPatches::TypeCasterConnectionConnectionPatch

Defined in:
lib/active_record_shards/default_replica_patches.rb

Instance Method Summary collapse

Instance Method Details

#connectionObject



256
257
258
259
260
261
262
263
264
265
# File 'lib/active_record_shards/default_replica_patches.rb', line 256

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