grape-entity icon indicating copy to clipboard operation
grape-entity copied to clipboard

Sending an array of hash

Open DamienCompere opened this issue 4 years ago • 1 comments

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 ?

DamienCompere avatar Jan 19 '21 17:01 DamienCompere

please use ruby-grape for questions

LeFnord avatar Feb 18 '21 14:02 LeFnord