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

Saving with nested parameters doesn't work #31

Closed
jgadbois opened this issue Nov 11, 2015 · 7 comments · Fixed by #32
Closed

Saving with nested parameters doesn't work #31

jgadbois opened this issue Nov 11, 2015 · 7 comments · Fixed by #32
Assignees
Labels

Comments

@jgadbois
Copy link
Contributor

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

@esbanarango
Copy link
Collaborator

Which version of ember-attachable are you using?
This should be already fixed (#14).

@esbanarango esbanarango self-assigned this Nov 11, 2015
@jgadbois
Copy link
Contributor Author

"ember-attachable": "^1.2.0",

@esbanarango
Copy link
Collaborator

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!

@jgadbois
Copy link
Contributor Author

Thanks!

@jgadbois
Copy link
Contributor Author

@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.

@jgadbois
Copy link
Contributor Author

@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]?

@jgadbois
Copy link
Contributor Author

Rails doesn't seem to like the [0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants