Method: ActiveRecord::ConnectionHandling#connecting_to
- Defined in:
- activerecord/lib/active_record/connection_handling.rb
#connecting_to(role: default_role, shard: default_shard, prevent_writes: false) ⇒ Object
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.
199 200 201 202 203 |
# File 'activerecord/lib/active_record/connection_handling.rb', line 199 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 |