Hi,
A few months ago I fixed a Rails bug that was yielding weird, unexpected
results when parsing form parameter names: effectively HWIA semantics
were screwing up UrlEncodedPairParser's parameter parsing when dealing
with nested values. This fixed the defect in question -- and thus solved
my immediate problem -- it raised wider questions about the actual
correctness and behavior of Rails' current parameter parsing code.
A colleague of mine recently ran into a related problem when dealing
with collections of records in Rails forms, which prompted me to finally
do something about the parameter parsing behavior. Now, while I'm sure
we're not the only ones hitting this wall, I'm aware that proposals to
change to the parameter parsing semantics in Rails is likely to be met
with a little caution, hesitation -- possibly even terror. :) With that
in mind, I've put up a plugin so everybody can give this a go without
having to apply any nasty patches:
http://www.vector-seven.com/git/rails/plugins/form...
Please see the README (attached) for the full details.
Be gentle, this is an early release that has been cobbled together over
the course of a few nights. We may not have everything right here, but
that's why it's being proposed as a plugin rather than yet another issue
in the tracker. It's hoped this will yield a wider discussion around the
semantics of parameter parsing in core Rails, because -- as it stands --
things can get a little screwy.
Looking forward to your feedback, suggestions and/or patches. If this
breaks your code in ways you don't expect, or doesn't quite work how you
would like/need it to, or if it's missing a feature that you'd kill to
have, I'd love to know.
Please be vocal. :)
Cheers,
Tom
on 2008-07-20 15:10
Re: Simplifying and fixing parameter parsing in Rails (Or: complex forms don't have to suck forever)
on 2008-07-20 20:59
Hi thomas, Sorry to top reply so briefly, but have you seen what david dollar and co have been discussing in the recent :accessible thread? http://groups.google.com/group/rubyonrails-core/t/... Sounds like your plugin here has some changes which could get merged along with his stuff. On Sun, Jul 20, 2008 at 3:09 PM, Thomas Lee <tom@vector-seven.com> wrote: > with collections of records in Rails forms, which prompted me to finally > > have, I'd love to know. > > 2. Parsing "a[b][0][c]=6" yields {"a" => {"b" => [{"c" => "6"}]}} > the exception of a few error cases (e.g. parsing "a/b@[c][d[e][]=f" yields > Example: > <input id="comments_0_id" name="comments[0][id]" type="hidden" value="1" /> > > Just install the plugin, and the new behavior should already be in effect. > > Copyright (c) 2008 Thomas Lee <tom@vector-seven.com>, released under the MIT license > > -- Cheers Koz
Re: Simplifying and fixing parameter parsing in Rails (Or: complex forms don't have to suck forever)
on 2008-07-23 00:55
Michael Koziarski wrote:
>
Sure does. Thanks for pointing that out. Looks like two sides of the
same coin. :)
Cheers,
T