Add Railtie config option: config.paper_trail.enabled
This commit is contained in:
parent
534aa778fb
commit
2029ea37ac
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
- [#689](https://github.com/airblade/paper_trail/pull/689) -
|
- [#689](https://github.com/airblade/paper_trail/pull/689) -
|
||||||
Rails 5 compatibility
|
Rails 5 compatibility
|
||||||
|
- Added a rails config option: `config.paper_trail.enabled`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -29,6 +30,8 @@
|
||||||
- [#635](https://github.com/airblade/paper_trail/issues/635) -
|
- [#635](https://github.com/airblade/paper_trail/issues/635) -
|
||||||
A bug where it was not possible to disable PT when using a multi-threaded
|
A bug where it was not possible to disable PT when using a multi-threaded
|
||||||
webserver.
|
webserver.
|
||||||
|
- [#584](https://github.com/airblade/paper_trail/issues/584) -
|
||||||
|
Fixed deprecation warning for Active Record after_callback / after_commit
|
||||||
|
|
||||||
## 4.1.0 (2016-01-30)
|
## 4.1.0 (2016-01-30)
|
||||||
|
|
||||||
|
|
|
@ -418,6 +418,13 @@ PaperTrail.enabled = false
|
||||||
|
|
||||||
This is commonly used to speed up tests. See [Testing](#testing) below.
|
This is commonly used to speed up tests. See [Testing](#testing) below.
|
||||||
|
|
||||||
|
There is also a rails config option that does the same thing.
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
# in config/environments/test.rb
|
||||||
|
config.paper_trail.enabled = false
|
||||||
|
```
|
||||||
|
|
||||||
### Per Request
|
### Per Request
|
||||||
|
|
||||||
Add a `paper_trail_enabled_for_controller` method to your controller.
|
Add a `paper_trail_enabled_for_controller` method to your controller.
|
||||||
|
|
|
@ -170,10 +170,6 @@ unless PaperTrail.active_record_protected_attributes?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ActiveSupport.on_load(:active_record) do
|
|
||||||
include PaperTrail::Model
|
|
||||||
end
|
|
||||||
|
|
||||||
# Require frameworks
|
# Require frameworks
|
||||||
require "paper_trail/frameworks/sinatra"
|
require "paper_trail/frameworks/sinatra"
|
||||||
if defined?(::Rails) && ActiveRecord::VERSION::STRING >= "3.2"
|
if defined?(::Rails) && ActiveRecord::VERSION::STRING >= "3.2"
|
||||||
|
|
|
@ -2,3 +2,7 @@
|
||||||
# since otherwise the model(s) will get loaded in via the `Rails::Engine`.
|
# since otherwise the model(s) will get loaded in via the `Rails::Engine`.
|
||||||
require "paper_trail/frameworks/active_record/models/paper_trail/version_association"
|
require "paper_trail/frameworks/active_record/models/paper_trail/version_association"
|
||||||
require "paper_trail/frameworks/active_record/models/paper_trail/version"
|
require "paper_trail/frameworks/active_record/models/paper_trail/version"
|
||||||
|
|
||||||
|
ActiveSupport.on_load(:active_record) do
|
||||||
|
include PaperTrail::Model
|
||||||
|
end
|
||||||
|
|
|
@ -2,6 +2,11 @@ module PaperTrail
|
||||||
module Rails
|
module Rails
|
||||||
class Engine < ::Rails::Engine
|
class Engine < ::Rails::Engine
|
||||||
paths["app/models"] << "lib/paper_trail/frameworks/active_record/models"
|
paths["app/models"] << "lib/paper_trail/frameworks/active_record/models"
|
||||||
|
config.paper_trail = ActiveSupport::OrderedOptions.new
|
||||||
|
initializer "paper_trail.initialisation" do |app|
|
||||||
|
ActiveRecord::Base.send :include, PaperTrail::Model
|
||||||
|
PaperTrail.enabled = app.config.paper_trail.fetch(:enabled, true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue