1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00

Remove deprecated rails engine config

This commit is contained in:
Jared Beck 2020-12-26 20:34:11 -05:00
parent ce2e055cef
commit 40c582b9fe
2 changed files with 5 additions and 36 deletions

View file

@ -7,7 +7,11 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
### Breaking Changes
- None
- In the PT rails engine, the `paper_trail` configuration has been
removed. This configuration object was deprecated in 10.2.0. Please review
docs section [2.d. Turning PaperTrail
Off](https://github.com/paper-trail-gem/paper_trail/#2d-turning-papertrail-off)
for alternatives.
### Added

View file

@ -4,42 +4,7 @@ module PaperTrail
module Rails
# See http://guides.rubyonrails.org/engines.html
class Engine < ::Rails::Engine
DPR_CONFIG_ENABLED = <<~EOS.squish.freeze
The rails configuration option config.paper_trail.enabled is deprecated.
Please use PaperTrail.enabled= instead. People were getting confused
that PT has both, specifically regarding *when* each was happening. If
you'd like to keep config.paper_trail, join the discussion at
https://github.com/paper-trail-gem/paper_trail/pull/1176
EOS
private_constant :DPR_CONFIG_ENABLED
DPR_RUDELY_ENABLING = <<~EOS.squish.freeze
At some point early in the rails boot process, you have set
PaperTrail.enabled = false. PT's rails engine is now overriding your
setting, and setting it to true. We're not sure why, but this is how PT
has worked since 5.0, when the config.paper_trail.enabled option was
introduced. This is now deprecated. In the future, PT will not override
your setting. See
https://github.com/paper-trail-gem/paper_trail/pull/1176 for discussion.
EOS
private_constant :DPR_RUDELY_ENABLING
paths["app/models"] << "lib/paper_trail/frameworks/active_record/models"
# --- Begin deprecated section ---
config.paper_trail = ActiveSupport::OrderedOptions.new
initializer "paper_trail.initialisation" do |app|
enable = app.config.paper_trail[:enabled]
if enable.nil?
unless PaperTrail.enabled?
::ActiveSupport::Deprecation.warn(DPR_RUDELY_ENABLING)
PaperTrail.enabled = true
end
else
::ActiveSupport::Deprecation.warn(DPR_CONFIG_ENABLED)
PaperTrail.enabled = enable
end
end
# --- End deprecated section ---
end
end
end