From 502342f19bdae9613d27f0f652ceebe927b1e4f3 Mon Sep 17 00:00:00 2001 From: Aaron Oehlschlaeger Date: Tue, 1 Jan 2019 16:52:03 -0800 Subject: [PATCH] update readme for disabling papertrail within initializer --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 71b05bef7..57bb42d99 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,6 @@ Syntax example: (options described in detail later) ```ruby # config/initializers/paper_trail.rb -PaperTrail.config.enabled = true PaperTrail.config.has_paper_trail_defaults = { on: %i[create update destroy] } @@ -292,10 +291,15 @@ PaperTrail.config.version_limit = 3 ```` These options are intended to be set only once, during app initialization (eg. -in `config/initializers`). It is unsafe to change them while the app is running. +in `config/initializers` or in an environment-specific configuration file such as +`config/environments/test.rb`). It is unsafe to change them while the app is running. In contrast, `PaperTrail.request` has various options that only apply to a single HTTP request and thus are safe to use while the app is running. +Note that `PaperTrails.config.enabled` will be overwritten if it is set within +`config/initializers`. For more information, see +[Turning PaperTrail Off](#2d-turning-papertrail-off) below. + ## 2. Limiting What is Versioned, and When ### 2.a. Choosing Lifecycle Events To Monitor @@ -503,6 +507,11 @@ PaperTrail.enabled = false **Do not use this in production** unless you have a good understanding of threads vs. processes. +Also note that PaperTrail can only be disabled globally during or after +environment-specific initialization. In other words, changes to +`PaperTrail.enabled` (or its alias `PaperTrail.config.enabled`) in +`config/initializers` will be overwritten. + A legitimate use case is to speed up tests. See [Testing](#7-testing) below. There is also a rails config option that does the same thing.