From 9da4930ab5d786c5fb8fec33a0d270eed1b2ca55 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Wed, 22 May 2013 10:58:42 -0400 Subject: [PATCH] Refactoring default :user_for_paper_trail method so that 'current_user' only gets invoked if it is defined. Close #228 --- CHANGELOG.md | 2 ++ lib/paper_trail/controller.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40eca831b..744084c65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 2.7.2 (Unreleased) + - [#228](/~https://github.com/airblade/paper_trail/issues/228) - Refactored default `user_for_paper_trail` method implementation + so that `current_user` only gets invoked if it is defined. - [#219](/~https://github.com/airblade/paper_trail/pull/219) - Fixed issue where attributes stored with `nil` value might not get reified properly depending on the way the serializer worked. - [#187](/~https://github.com/airblade/paper_trail/pull/187) - Confirmed JRuby support. diff --git a/lib/paper_trail/controller.rb b/lib/paper_trail/controller.rb index 974d1c7c9..6bbbe70aa 100644 --- a/lib/paper_trail/controller.rb +++ b/lib/paper_trail/controller.rb @@ -14,7 +14,7 @@ def self.included(base) # Override this method in your controller to call a different # method, e.g. `current_person`, or anything you like. def user_for_paper_trail - current_user rescue nil + current_user if defined?(current_user) end # Returns any information about the controller or request that you