Module: ActiveRecordShards::DefaultReplicaPatches::Rails52RelationPatches

Defined in:
lib/active_record_shards/default_replica_patches.rb

Instance Method Summary collapse

Instance Method Details

#connectionObject



107
108
109
110
111
112
113
114
115
116
# File 'lib/active_record_shards/default_replica_patches.rb', line 107

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

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