instance method
connected_to_all_shards
Ruby on Rails edge
Since v8.0.5.1Signature
connected_to_all_shards(role: nil, prevent_writes: role == ActiveRecord.reading_role, &blk)
Passes the block to connected_to for every shard the model is configured to connect to, and returns the results in an array. Raises an ArgumentError if the model is not connected to any shards.
Optionally, role and/or prevent_writes can be passed which will be forwarded to each connected_to call. prevent_writes defaults to true when using the reading role.
Parameters
-
rolekey = nil -
prevent_writeskey = role == ActiveRecord.reading_role -
blkblock
Source
# File activerecord/lib/active_record/connection_handling.rb, line 200
def connected_to_all_shards(role: nil, prevent_writes: role == ActiveRecord.reading_role, &blk)
if shard_keys.empty?
raise ArgumentError, "`connected_to_all_shards` cannot be called on a model that is not connected to any shards."
end
shard_keys.map do |shard|
connected_to(shard: shard, role: role, prevent_writes: prevent_writes, &blk)
end
end
Defined in activerecord/lib/active_record/connection_handling.rb line 200
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionHandling