Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

has_many_association: Deal with empty 204 status code #540

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pedrolucasp
Copy link

If you register a relationship as a has_many and you this resource
endpoint return a 204 we should handle this gracefully, by returning a
empty array. This patch leverages the default return type defined on the
relationship (@opts[:default]) to construct which sort of response it
would expect (get_collection or a regular get).

The default parser, is dumb and therefore cannot distinguish if when it
receives a 204 it should transform that into a hash or an array, and
always convert the response into a empty hash. So, on the
attributes.rb method called instantiate_collection when we stumble
upon a empty hash we always convert into an empty array.

If you register a relationship as a `has_many` and you this resource
endpoint return a 204 we should handle this gracefully, by returning a
empty array. This patch leverages the default return type defined on the
relationship (`@opts[:default]`) to construct which sort of response it
would expect (`get_collection` or a regular `get`).

The default parser, is dumb and therefore cannot distinguish if when it
receives a 204 it should transform that into a hash or an array, and
always convert the response into a empty hash. So, on the
attributes.rb method called `instantiate_collection` when we stumble
upon a empty hash we always convert into an empty array.
@pedrolucasp
Copy link
Author

Hello, just a quick ping on this PR for review @remi @zacharywelch :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant