Permalink
Browse files

Default value for :user_for_paper_trail method should try to return a…

…n id instead of an object. close #316
  • Loading branch information...
1 parent 6893431 commit b36780e708ac1c732b0c9becea12278346390140 @batter batter committed Feb 11, 2014
View
@@ -1,6 +1,8 @@
## 3.0.1 (Unreleased)
- - [#313](https://github.com/airblade/paper_trail/pull/313) - Make the rails controller helper compatible with
+ - [#316](https://github.com/airblade/paper_trail/issues/316) - `user_for_paper_trail` should default to `current_user.try(:id)`
+ instead of `current_user` (if `current_user` is defined).
+ - [#313](https://github.com/airblade/paper_trail/pull/313) - Make the `Rails::Controller` helper compatible with
`ActionController::API` for compatibility with the [`rails-api`](https://github.com/rails-api/rails-api) gem.
## 3.0.0
@@ -17,7 +17,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 if defined?(current_user)
+ current_user.try(:id) if defined?(current_user)
end
# Returns any information about the controller or request that you
@@ -15,7 +15,7 @@ def self.registered(app)
# 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 if defined?(current_user)
+ current_user.try(:id) if defined?(current_user)
end
private
@@ -7,7 +7,7 @@ def rescue_action(e)
# Returns id of hypothetical current user
def current_user
- 153
+ @current_user ||= OpenStruct.new(:id => 153)
end
def info_for_paper_trail
@@ -1,5 +1,5 @@
class TestController < ActionController::Base
- def current_user
+ def user_for_paper_trail
Thread.current.object_id
end
end
@@ -12,7 +12,7 @@ class BaseApp < Sinatra::Base
end
def current_user
- 'foobar'
+ @current_user ||= OpenStruct.new(:id => 'foobar')
end
end
@@ -12,7 +12,7 @@ class Sinatra::Application
end
def current_user
- 'raboof'
+ @current_user ||= OpenStruct.new(:id => 'raboof')
end
end

0 comments on commit b36780e

Please sign in to comment.