Default value for :user_for_paper_trail method should try to return an id instead of an object. close #316

This commit is contained in:
Ben Atkins 2014-02-11 11:08:58 -05:00
parent 6893431f15
commit b36780e708
7 changed files with 9 additions and 7 deletions

View File

@ -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

View File

@ -17,7 +17,7 @@ module PaperTrail
# 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

View File

@ -15,7 +15,7 @@ module PaperTrail
# 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

View File

@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
# Returns id of hypothetical current user
def current_user
153
@current_user ||= OpenStruct.new(:id => 153)
end
def info_for_paper_trail

View File

@ -1,5 +1,5 @@
class TestController < ActionController::Base
def current_user
def user_for_paper_trail
Thread.current.object_id
end
end

View File

@ -12,7 +12,7 @@ class BaseApp < Sinatra::Base
end
def current_user
'foobar'
@current_user ||= OpenStruct.new(:id => 'foobar')
end
end

View File

@ -12,7 +12,7 @@ class Sinatra::Application
end
def current_user
'raboof'
@current_user ||= OpenStruct.new(:id => 'raboof')
end
end