Skip to content

Grape::Entity::Delegator::HashObject fails when extracting string keys #223

Open
@tom-mayer

Description

@tom-mayer

Hi,

I was trying to present a hash of values with a grape entity. The keys in the hash were strings and I got null values all over the place as a response.

It boils down to Grape::Entity::Delegator::HashObject, when it tries to render the attribute it only tries to extract the attribute with a symbol as a key and not a string.

screen shot 2016-05-30 at 13 50 29

I think a simple
object[attribute] || object[attribute.to_s]
would fix the issue, although I'm not sure whether you need to make the destinction between symbols and strings there for other reasons. For now I simple convert all my keys to symbols before handing them to grape entity. But in any case would be more convenient the other way around.

Cheers
Tom

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions