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

Does this support nested params? #27

Open
prathamesh-sonpatki opened this issue Mar 22, 2013 · 3 comments
Open

Does this support nested params? #27

prathamesh-sonpatki opened this issue Mar 22, 2013 · 3 comments

Comments

@prathamesh-sonpatki
Copy link

I want to send some nested params with the file. Is it not getting send properly.

For example

     sub_params = { contact: { 'first_name' => 'prathamesh', 'language' => 'Ruby' } }
     params     = sub_params.merge({ "file" => UploadIO.new(csv, "text/csv", "test.csv") })
     request    = Net::HTTP::Post::Multipart.new(url.path, params)     

On Rails side, i get

Parameters: {"contact"=>"{\"first_name\"=>\"prathamesh\", \"language\"=>\"Ruby\"}", "file"=>#<ActionDispatch::Http::UploadedFile:0x0000000628cea8 ....}

Nested attributes first_name and language are delimited. But they should be not.

Right now, parts are created assuming that value is String. So it is failing here where value is Hash like in case of nested hash.

@nicosantangelo
Copy link

I would like this to be implemented too, but you could do something like this:

     sub_params = { :'contact[first_name]' => 'prathamesh', :'contact[language]' => 'Ruby' }
     params     = sub_params.merge({ "file" => UploadIO.new(csv, "text/csv", "test.csv") })
     request    = Net::HTTP::Post::Multipart.new(url.path, params)

to get the desired params in Rails.

@gernberg
Copy link
Contributor

@nicosantangelo / @prathamesh-sonpatki , if you just continue the work I did i my pull request (#30) I think you can solve this pretty easy :-)

@ioquatix
Copy link
Member

ioquatix commented May 3, 2017

It would be good to support this. PR welcome.

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

4 participants