Module: ActiveRecordShards::DefaultReplicaPatches::Rails52RelationPatches

Defined in:
lib/active_record_shards/default_replica_patches.rb

Instance Method Summary collapse

Instance Method Details

#connectionObject



150
151
152
153
154
155
156
157
158
159
# File 'lib/active_record_shards/default_replica_patches.rb', line 150

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