Yes, the receiving end is a rails app. It worked. Thanks a lot.

On Monday, January 5, 2015 7:42:30 PM UTC+5:30, Frederick Cheung wrote:
>
>
> On Monday, January 5, 2015 1:05:14 PM UTC, Kriti Aggarwal wrote:
>>
>> Hi guys,
>>
>> I am trying to send arrays using POST in rails 4.0. But instead of 
>> sending the whole array, it seems to send only the last value in the array. 
>> I used the following code snippet:
>>
>>     uri = URI.parse('http://localhost:3000/abc')
>>>
>>     http = Net::HTTP.new(uri.host, uri.port)
>>>
>>     request = Net::HTTP::Post.new(uri)
>>>
>>     request.set_form_data(set_params(args_hash))
>>>
>>     response = http.request(request)
>>>
>>
>> I also tried using 'httpparty' gem for the same, but it is also showing 
>> an error.
>>
>> Can anyone point out as to what I am doing wrong? What is the best way of 
>> sending arrays using POST in Rails?
>>
>>
> Is the receiving end a rails app? if so then the parameter name must end 
> in [] for rails to treat it as an array (for example "names[]" will result 
> in params[:names] being an array)
>
> Fred
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/5dd972dc-1ea4-42ac-938c-92d88ecfd0f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to