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

Request with include option, not parsing correctly #24

Open
ristovskiv opened this issue Jul 26, 2018 · 0 comments
Open

Request with include option, not parsing correctly #24

ristovskiv opened this issue Jul 26, 2018 · 0 comments

Comments

@ristovskiv
Copy link
Contributor

Hey guys when using the include param for including an association in the response along with some specific fields, with the current implementation I think it is a bit buggy and it doesn't parse the response in the intended way. I've posted a PR where the spec for that feature is more precise, and that spec fails.
The reason behind this is using as_json on the strong params of :include option in the json render which will transform the strong params object into a Hash object with all its keys deeply converted into strings.
Because of that, since we are using as_json on the Model and we have a Hash with keys as strings under the :include key, regardless of the version of rails it will include the associated model with all of its attributes.
https://github.com/rails/rails/blob/master/activemodel/lib/active_model/serializers/json.rb#L89-L102
https://github.com/rails/rails/blob/master/activemodel/lib/active_model/serialization.rb#L130

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

No branches or pull requests

1 participant