instance method
connecting_to
Ruby on Rails 7.1.6
Since v6.1.7.10Signature
connecting_to(role: default_role, shard: default_shard, prevent_writes: false)
Use a specified connection.
This method is useful for ensuring that a specific connection is being used. For example, when booting a console in readonly mode.
It is not recommended to use this method in a request since it does not yield to a block like connected_to.
Parameters
-
rolekey = default_role -
shardkey = default_shard -
prevent_writeskey = false
Source
# File activerecord/lib/active_record/connection_handling.rb, line 185
def connecting_to(role: default_role, shard: default_shard, prevent_writes: false)
prevent_writes = true if role == ActiveRecord.reading_role
append_to_connected_to_stack(role: role, shard: shard, prevent_writes: prevent_writes, klasses: [self])
end
Defined in activerecord/lib/active_record/connection_handling.rb line 185
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionHandling