Skip to content

Request with include option, not parsing correctly #24

Description

@ristovskiv

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions