mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Fix bug displaying nil for relationship link href
When using the relationship link with a block, calling "meta" without "href", e.g.
has_one :bio do
link :related do
meta id: 1
end
end
results in in a nil "href", e.g.
{ links: { posts: { related: { href: nil, meta: { id: 1 } } } } }.
According to JSONAPI, we should be able to use meta without href
(http://jsonapi.org/format/#document-links).
This commit is contained in:
@@ -28,8 +28,9 @@ module ActiveModel
|
||||
def as_json
|
||||
return @value if @value
|
||||
|
||||
hash = { href: @href }
|
||||
hash.merge!(meta: @meta) if @meta
|
||||
hash = {}
|
||||
hash[:href] = @href if @href
|
||||
hash[:meta] = @meta if @meta
|
||||
|
||||
hash
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user