method

connected_to?

Importance_2
v7.1.3.2 - Show latest stable - 0 notes - Class: ConnectionHandling
connected_to?(role:, shard: ActiveRecord::Base.default_shard) public

Returns true if role is the current connected role and/or current connected shard. If no shard is passed, the default will be used.

ActiveRecord::Base.connected_to(role: :writing) do
  ActiveRecord::Base.connected_to?(role: :writing) #=> true
  ActiveRecord::Base.connected_to?(role: :reading) #=> false
end

ActiveRecord::Base.connected_to(role: :reading, shard: :shard_one) do
  ActiveRecord::Base.connected_to?(role: :reading, shard: :shard_one) #=> true
  ActiveRecord::Base.connected_to?(role: :reading, shard: :default) #=> false
  ActiveRecord::Base.connected_to?(role: :writing, shard: :shard_one) #=> true
end
Show source
Register or log in to add new notes.