mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Don't embed empty associations in root
This commit is contained in:
committed by
Santiago Pastorino
parent
3e510c829b
commit
cec7980208
@@ -46,7 +46,9 @@ module ActiveModel
|
||||
def embedded_in_root_associations
|
||||
@object.each_with_object({}) do |item, hash|
|
||||
serializer_for(item).embedded_in_root_associations.each_pair do |type, objects|
|
||||
if hash[type]
|
||||
next if !objects || objects.flatten.empty?
|
||||
|
||||
if hash.has_key?(type)
|
||||
hash[type].concat(objects).uniq!
|
||||
else
|
||||
hash[type] = objects
|
||||
|
||||
Reference in New Issue
Block a user