instance method connected_to_all_shards

Ruby on Rails edge

Since v8.0.5.1

Available in: v8.0.5.1 v8.1.3.1 edge

Signature

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

role key = nil
prevent_writes key = role == ActiveRecord.reading_role
blk block
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

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close