Proposal: Params are a multi-hash
Reported by Yehuda Katz | February 11th, 2009 @ 11:41 PM
The current state of affairs with regard to parsing params.
For: "foo=bar&foo=baz"
{"foo" => "bar"} # rails
{"foo" => "baz"} # merb
{"foo" => ["bar", "baz"]}
Proposal: Use a MultiHash Object
This idea is cribbed from the WebOb Python framework, which provides some core objects for the WSGI spec.
Semantics
params["foo"] #=> "baz"
params.all("foo") #=> ["bar", "baz"]
params.each do |key, value|
p [key, value]
end
#=> ["foo", "baz"]
The initial implementation also handles update, update!, merge, merge!, delete, and supplies each_array, which yields [key, values] to the block.
The initial motivation for this was correctly handling checkboxes that supply both a "yes" and "no" value when checked (["1","0"] in Rails and ["0","1"] in Merb) and a "no" value when not checked ("0").
Comments and changes to this ticket
-
Yehuda Katz February 12th, 2009 @ 12:00 AM
Whoops... I forgot to include support for merge, update, and at that I had added.
-
josh February 17th, 2009 @ 04:01 PM
- State changed from new to wontfix
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป