This project is archived and is in readonly mode.

#2334 ✓resolved
Gregg Kellogg

Hash.from_xml fieldnames uncamelizing

Reported by Gregg Kellogg | March 25th, 2009 @ 07:19 AM | in 3.x

Calling Hash.from_xml with CamelCase element and attribute names causes the names to be underscored.

From http://www.bluequartz.us/phpBB2/...

xml = %(<blah_blah> 1 2 <dasherized_tag> 3 </dasherized_tag> </blah_blah>)

h = Hash.from_xml(xml)

assert_equal(h, {"blah_blah" => {"JunkOne" => "1", "JunkTwo" => "2", "dasherized_tag" => "3"}})

notice that regardless of the tag name the key is the same string. what rails is currently doing is giving me a result that looks like this: {"blah_blah" => {"junk_one" => "1", "junk_two" => "2", "dasherized_tag" => "3"}}

The bug results from a change to ActiveSupport::CoreExtensions::Hash::Conversions::ClassMethods::unrename_keys which used to be:

h[k.to_s.tr("-", "_")] = unrename_keys(v)

Comments and changes to this ticket

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages