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:
Lee Richmond
2016-09-19 14:10:50 -04:00
committed by L. Preston Sego III
parent a032201a91
commit a77dfdaa85
3 changed files with 3 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ module ActiveModelSerializers
meta = meta_for(association)
hash[:meta] = meta if meta
hash[:meta] = {} if hash.empty?
hash
end