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:
parent
6893431f15
commit
b36780e708
|
@ -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 @@ 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue