mirror of
https://github.com/samsonjs/grape-active_model_serializers.git
synced 2026-03-25 08:45:55 +00:00
fix: when resource is empty, keep json resource root
This commit is contained in:
parent
e30af569b2
commit
94a6122c9e
1 changed files with 2 additions and 4 deletions
|
|
@ -18,10 +18,8 @@ module Grape
|
|||
|
||||
if serializer = options.fetch(:serializer, ActiveModel::Serializer.serializer_for(resource))
|
||||
options[:scope] = serialization_scope unless options.has_key?(:scope)
|
||||
if resource.respond_to?(:to_ary) && !resource.empty?
|
||||
# ensure we have an root to fallback on
|
||||
options[:resource_name] = default_root(endpoint)
|
||||
end
|
||||
# ensure we have an root to fallback on
|
||||
options[:resource_name] = default_root(endpoint) if resource.respond_to?(:to_ary)
|
||||
serializer.new(resource, options.merge(other_options))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue