Saving with nested parameters doesn't work
Closed this issue · 7 comments
I have a serializer that has nested JSON. For example:
{ name: "Name", images: [ { name: 'name1' }, { name: 'name2' }]
The images array is sent to the server as
------WebKitFormBoundaryvK7rWGag7SLFw5wi
Content-Disposition: form-data; name="product[images][]"
[object Object]
If .save
is called it works fine, breaks with .saveWithAttachment
Which version of ember-attachable
are you using?
This should be already fixed (#14).
"ember-attachable": "^1.2.0",
You're right, we're not handling that case for arrays when adding data to the FormData
object. I'll fix this later today. Thank you!
Thanks!
@esbanarango were you able to fix this? I forked the repo and started looking at it myself, but didn't find a great way to test.
@esbanarango I almost have a pull ready - quick question about the format.
My pull is currently producing:
------WebKitFormBoundary1cdo7F8rfPzzRS3h
Content-Disposition: form-data; name="product[files][0][id]"
39
------WebKitFormBoundary1cdo7F8rfPzzRS3h
Content-Disposition: form-data; name="product[files][0][name]"
IMG_0417.JPG
Is that correct or should it be product[files][][name]
also how should nested arrays look?
Maybe like product[files][][][name]
OR product[files][0][0][name]
?
Rails doesn't seem to like the [0]