In Rails, when you want to send a list of values through a single array parameter, you usually do so by suffixing the URL parameter key with []
. For example, the query string ?foo[]=1&foo[]=2&foo[]=3
is parsed as
params = { "foo" => [ 1, 2, 3 ] }
But for ?foo=1&foo=2&foo=3
, only the last argument shows up in the params hash:
params = { "foo" => 3 }
Everything's fine while you can control the URL format; you can just use the []
syntax. But what if the URL is constructed by a remote system that you cannot influence, and that insists on the second format? How can one get the arguments unpacked properly?