mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Reference scope by same name as serialization scope
By default, the serialization scope uses current_user, and you can now reference the scope as "current_user" in the serializer. If you override the scope using "serialization_scope" in your controller, it will use that method name instead.
This commit is contained in:
@@ -31,6 +31,7 @@ module ActiveModel
|
||||
if serializer
|
||||
serialization_scope = controller.send(:serialization_scope)
|
||||
options[:scope] = serialization_scope unless options.has_key?(:scope)
|
||||
options[:scope_name] = controller.send(:_serialization_scope)
|
||||
options[:url_options] = controller.send(:url_options)
|
||||
render(given_options.merge(self.options).merge(:json => serializer.new(resource, options)))
|
||||
else
|
||||
@@ -40,4 +41,4 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user