Skip to content

Commit ff01ba2

Browse files
committed
Merge pull request #647 from gauthier-delacroix/Fix-embed_in_root_key-merging
Fix embed_in_root_key merging
2 parents da81c97 + a862929 commit ff01ba2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/active_model/array_serializer.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ def embedded_in_root_associations
5151
next if !objects || objects.flatten.empty?
5252

5353
if hash.has_key?(type)
54-
hash[type].concat(objects).uniq!
54+
case hash[type] when Hash
55+
hash[type].deep_merge!(objects){ |key, old, new| (Array(old) + Array(new)).uniq }
56+
else
57+
hash[type].concat(objects).uniq!
58+
end
5559
else
5660
hash[type] = objects
5761
end

0 commit comments

Comments
 (0)