Skip to content

Attributes on resources should be converted to symbol before storing in @_attributes #1032

@hidde-jan

Description

@hidde-jan

Defining attribute "string_name" on a resource results to that string being used as the key for storing the attributes options in the @_attributes instance variable in https://github.com/cerebris/jsonapi-resources/blob/9f34830572094a7aa74fa7ccd91095fdc9fea529/lib/jsonapi/resource.rb#L519 (instead of a symbol).

This in turn leads to problems down the road, for instance in RequestParser, which converts incoming attributes from the params from the to symbols before passing it to resource_klass._attribute_options in https://github.com/cerebris/jsonapi-resources/blob/9f34830572094a7aa74fa7ccd91095fdc9fea529/lib/jsonapi/request_parser.rb#L573 leading to problems in https://github.com/cerebris/jsonapi-resources/blob/9f34830572094a7aa74fa7ccd91095fdc9fea529/lib/jsonapi/resource.rb#L754

Solution: convert attr to a symbol in https://github.com/cerebris/jsonapi-resources/blob/9f34830572094a7aa74fa7ccd91095fdc9fea529/lib/jsonapi/resource.rb#L509

This is a duplicate of #1019, but that issue is pretty vague w.r.t. what's the issue.

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