-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Expected behavior vs actual behavior
Expect to set
serialization_scope :view_context
in application_controller.rb
And in serializer:
delegate :current_user, to: :scope
and then access current_user in serializer.
Actual:
IssueSerializer#current_user delegated to scope.current_user, but scope is nil:...
Steps to reproduce
See above:
Set serialization_scope :view_context in application_controller.rb, delegate current_user to scope in serializer, try to access current_user in serializer.
Environment
ActiveModelSerializers Version (commit ref if not on tag): 0.10.6
Output of ruby -e "puts RUBY_DESCRIPTION": 2.3.1p112
OS Type & Version: OSX 10.12.4
Integrated application and version (e.g., Rails, Grape, etc): Rails 5.1
Backtrace
(e.g., provide any applicable backtraces from your application)
Module::DelegationError (IssueSerializer#current_user delegated to scope.current_user, but scope is nil: #<IssueSerializer:0x007fbd370c8bf8 @object=#<Issue id: 22, title: ...data removed>, @scope=nil, @root=nil, @polymorphic=false, @meta_key=:meta, @meta=nil, @wrap_in_array=nil, @only=nil, @except=nil, @key_format=nil, @context=nil, @namespace=nil, @serialization_options={}>):