to_xml给出了奇怪的结果

sta*_*p75 5 xml ruby-on-rails

当我这样做

{"New York"=>33, :Versailles => 3231}.to_xml
Run Code Online (Sandbox Code Playgroud)

我明白了

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<hash>
  <Versailles type=\"integer\">3231</Versailles>
  <New York type=\"integer\">33</New York>
</hash>
Run Code Online (Sandbox Code Playgroud)

我原本以为轨道会把"纽约"称为"纽约",不是吗?

Pra*_*thy 2

此问题通过合并拉取请求 445 来解决:https ://github.com/rails/rails/pull/445

空间现在将被 dasherized(并且私有 _dasherize 方法得到增强以处理空间。)

{"New York"=>33}.to_xml 将导致

..<New-York type=\"integer\">33</New-York>..

感谢您提出这张灯塔票和 stackoverflow 问题(在讨论中添加了更多信息);在提供的所有信息的帮助下,我能够进行第一次 Rails 提交!