class ActiveModel::ArraySerializer
def embedded_in_root_associations
def embedded_in_root_associations @object.each_with_object({}) do |item, hash| serializer_for(item).embedded_in_root_associations.each_pair do |type, objects| next if !objects || objects.flatten.empty? if hash.has_key?(type) hash[type].concat(objects).uniq! else hash[type] = objects end end end end