Here is a ruby hash:
a = {
:testOne => 1,
:testTwo => 2
}
How can I rename the keys so that they are underscored?
a = {
:test_one => 1,
:test_two => 2
}
Ken Bloom got me on the right tract here. You do need ActiveSupport or Rails3. You don't need any specific gems for this solution however:
hash = Hash[a.map {|k,v| [k.to_s.underscore.to_sym, v]}]
Thanks ken!