Type only post requests#153
Merged
dgeb merged 4 commits intoJSONAPI-Resources:masterfrom Apr 8, 2015
adamworrall:type-only-post-requests
Merged
Type only post requests#153dgeb merged 4 commits intoJSONAPI-Resources:masterfrom adamworrall:type-only-post-requests
dgeb merged 4 commits intoJSONAPI-Resources:masterfrom
adamworrall:type-only-post-requests
Conversation
POST with only 'type' key is not triggering a save on the activerecord model, but no errors are reported. This leads to an incorrect 201 status.
Resource#create_model instantiates an activerecord model, but doesn't trigger a save. The save comes in _replace_fields, but if field_data[:attributes] is empty it never sets @save_needed. I'm sure this isn't the best way to solve this issue, but it works for now.
Merged
Contributor
|
👍 |
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.
First shot at addressing POST where the data object only contains a "type" member.
Relates to discussion in #151. Created resources with only "type" in the data don't get @save_needed set, so they never actually save the ActiveRecord model and they don't get a change to generate validation errors, leading to incorrect 201 status.
I've added an explicit check to Resource#change to save if the object is_new, but that's ugly. Any thoughts on where this should be fixed?