From 82217c21703d7b94a61c778748e9ccd354fd105c Mon Sep 17 00:00:00 2001 From: eileencodes Date: Mon, 21 Sep 2020 15:57:38 -0400 Subject: [PATCH] Improve while_preventing_writes documentation Adds a note to clarify that `while_preventing_writes` is not meant to be a replacement for a readonly replica user. Closes #39132 and #39133 Co-authored-by: Eike Send --- .../connection_adapters/abstract/connection_pool.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index 70e48de940..6bda8888b7 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -1015,6 +1015,12 @@ def prevent_writes=(prevent_writes) # :nodoc: # In some cases you may want to prevent writes to the database # even if you are on a database that can write. `while_preventing_writes` # will prevent writes to the database for the duration of the block. + # + # This method does not provide the same protection as a readonly + # user and is meant to be a safeguard against accidental writes. + # + # See `READ_QUERY` for the queries that are blocked by this + # method. def while_preventing_writes(enabled = true) original, self.prevent_writes = self.prevent_writes, enabled yield -- GitLab