mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Ensure valid jsonapi when blank relationship (#1930)
If you specify include_data false, and do not have any links for this
relationship, we would output something like:
`{ relationships: { comments: {} } }`
This is not valid jsonapi. We will now render
`{ relationships: { comments: { meta: {} } } }`
Instead.
Relevant jsonapi spec: http://jsonapi.org/format/#document-resource-object-relationships
This commit is contained in:
committed by
L. Preston Sego III
parent
a032201a91
commit
a77dfdaa85
@@ -24,6 +24,7 @@ module ActiveModelSerializers
|
||||
|
||||
meta = meta_for(association)
|
||||
hash[:meta] = meta if meta
|
||||
hash[:meta] = {} if hash.empty?
|
||||
|
||||
hash
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user