#31 ✓wontfix
Yehuda Katz

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

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Attachments

Pages