Skip to content

Sending an array of hash #344

@DamienCompere

Description

@DamienCompere

When I try to send an array of hash, I have the error instance of ActiveSupport::HashWithIndifferentAccess

Here is my model :
expose :book, documentation: { type: Array[Hash] }
And in my controller I have nested attributes like this :
requires :collection, type: Hash do optional :book, type: Array do requires :id, type: String requires :price, type: BigDecimal end end

When I check in my console the params book, I have an array with a hash :
[{"id"=>"351a7eaf-cf93-4f89-9f3a-b2cce4c07a70", "amount"=>0.23e2}]
But it returns the error Collection::book(#11898309) expected, got {"id"=>"351a7eaf-cf93-4f89-9f3a-b2cce4c07a70", "amount"=>0.23e2} which is an instance of ActiveSupport::HashWithIndifferentAccess(#510440)
Do you know what's wrong here ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions