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

Sending an array of hash #344

Open
DamienCompere opened this issue Jan 19, 2021 · 1 comment
Open

Sending an array of hash #344

DamienCompere opened this issue Jan 19, 2021 · 1 comment

Comments

@DamienCompere
Copy link

DamienCompere commented Jan 19, 2021

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 ?

@LeFnord
Copy link
Member

LeFnord commented Feb 18, 2021

please use ruby-grape for questions

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

2 participants