Fix bug where PaperTrail was disabled in controller by default.
This commit is contained in:
parent
7395e5afe2
commit
3b99221015
|
@ -20,12 +20,14 @@ module PaperTrail
|
|||
!!PaperTrail.config.enabled
|
||||
end
|
||||
|
||||
# Returns `true` if PaperTrail is enabled for the controller, `false` otherwise.
|
||||
# Returns `true` if PaperTrail is enabled for the request, `false` otherwise.
|
||||
#
|
||||
# See `PaperTrail::Controller#paper_trail_enabled_for_controller`.
|
||||
def self.enabled_for_controller?
|
||||
!!paper_trail_store[:request_enabled_for_controller]
|
||||
end
|
||||
|
||||
# Sets if PaperTrails is disabled by controller
|
||||
# Sets whether PaperTrail is enabled or disabled for the current request.
|
||||
def self.enabled_for_controller=(value)
|
||||
paper_trail_store[:request_enabled_for_controller] = value
|
||||
end
|
||||
|
|
|
@ -39,13 +39,20 @@ module PaperTrail
|
|||
{}
|
||||
end
|
||||
|
||||
# Returns `true` (default) or `false` depending on whether PaperTrail should
|
||||
# be active for the current request.
|
||||
#
|
||||
# Override this method in your controller to specify when PaperTrail should
|
||||
# be off.
|
||||
def paper_trail_enabled_for_controller
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Tells PaperTrail if version should be saved.
|
||||
# Tells PaperTrail whether versions should be saved in the current request.
|
||||
def set_paper_trail_enabled_for_controller
|
||||
if respond_to? :paper_trail_enabled_for_controller
|
||||
::PaperTrail.enabled_for_controller = paper_trail_enabled_for_controller
|
||||
end
|
||||
::PaperTrail.enabled_for_controller = paper_trail_enabled_for_controller
|
||||
end
|
||||
|
||||
# Tells PaperTrail who is responsible for any changes that occur.
|
||||
|
|
Loading…
Reference in New Issue