Right now when passing parameters through jQuery, it serializes something
like:
{ order: [{ name: "last_name", dir: "asc" }, name: "first_name", dir:
"asc" }] }
Into:
order%5B0%5D%5Bname%5D=last_name&order%5B0%5D%5Bdir%5D=asc&order%5B1%5D%5Bname%5D=first_name&order%5B1%5D%5Bdir%5D=asc
Then on the Rails side, it gets interpreted as:
{"order"=>{"0"=>{"name"=>"last_name", "dir"=>"asc"},
"1"=>{"name"=>"first_name", "dir"=>"asc"}}}
At first thought it looked like a bug, but it's really a problem with how
the serialization/deserialization can be interpreted. Here's an article
that goes further into it:
http://benalman.com/news/2009/12/jquery-14-param-demystified
Since this is such a common problem, can something be built into Rails to
handle it? I would love if it worked by default, but I guess since you
might sometimes want the current output, maybe there's a flag that can be
passed to tell Rails to convert the hash into an array. Let me know if
there are better alternatives.
I know there are some solutions available, such as using JSON.stringify,
but that won't work with GET requests.
Thanks,
Tom
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.