Get relationship id from the resource#809
Merged
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom Aug 31, 2016
Merged
Conversation
We should avoid getting relationship id from the `model` directly to allow clients to customize how relationship ids are fetched. The resource exposes the relationship id through a method which delegates to the `model`. This way we allow clients to override the relationship id in the resource to fit their needs.
Contributor
|
+1 |
Contributor
|
@gottfrois Thanks! |
NuckChorris
referenced
this pull request
in hummingbird-me/kitsu-server
Dec 12, 2016
NuckChorris
referenced
this pull request
in hummingbird-me/kitsu-server
Dec 12, 2016
* Use jsonapi-resources beta * Disable fields picking in feeds * Disable eager_load_on_include on activity/activitygroup models * Use ResourceSerializer directly * Fix that * Override cerebris/jsonapi-resources#809 behavior * Override BaseResource#respond_to? to handle FK _id methods properly * Oops * Try and add caching to various models * Stop caching ActivityGroups * Cache Post, PostLike, Comment
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.
We should avoid getting relationship id from the
modeldirectly to allow clients to customize how relationship ids are fetched. The resource exposes the relationship id through a method which delegates to themodel. This way we allow clients to override the relationship id in the resource to fit their needs.Today, by default, the resource object already delegate the relationship id method to the model:
This way, a client can override the relationship id method: