Fix bug displaying nil for relationship link href - #1516
Merged
Merged
Conversation
groyoh
force-pushed
the
fix_relationship_href
branch
2 times, most recently
from
February 13, 2016 13:47
a1d7bf9 to
37ce6e3
Compare
|
|
||
| Fixes: | ||
| - [#1516](https://github.com/rails-api/active_model_serializers/pull/1501) Using only meta for relationship links would result | ||
| in a `nil` href. (@groyoh) |
Member
There was a problem hiding this comment.
No longer return a
nilhref when only adding meta to a relationship link.
?
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).
groyoh
force-pushed
the
fix_relationship_href
branch
from
February 15, 2016 08:27
37ce6e3 to
3cbc054
Compare
| has_many :locations do | ||
| link :related do | ||
| ids = object.locations.map!(&:id).join(',') | ||
| ids = object.locations.map(&:id).join(',') |
Member
Author
There was a problem hiding this comment.
I was using map! instead of map with actually change the array and might cause some issues.
Member
|
Looks good. |
bf4
added a commit
that referenced
this pull request
Feb 16, 2016
[FIX] bug displaying nil for relationship link href
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow up to #1504 (comment). When using the relationship link with a block, calling "meta" without "href", e.g.
results in in a nil "href".
According to JSONAPI, we should be able to use meta without href (http://jsonapi.org/format/#document-links).
Depending on the ouput from #1514, this PR might need some follow up.