mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
has_one serialized objects shouldn't be wrapped in an array and it's key is singular
This commit is contained in:
@@ -152,7 +152,8 @@ module ActiveModel
|
||||
if associated_data.respond_to?(:to_ary)
|
||||
associated_data.map { |elem| association.build_serializer(elem).serializable_hash }
|
||||
else
|
||||
[association.build_serializer(associated_data).serializable_hash]
|
||||
result = association.build_serializer(associated_data).serializable_hash
|
||||
association.is_a?(Association::HasMany) ? [result] : result
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user