Ruby 1.9.2 patchlevel 180 - libyaml 破坏 yaml 节点引用

发布于 2024-11-13 05:02:57 字数 535 浏览 3 评论 0原文

我使用rvm升级到1.9.2-p180。在安装过程中,获取并安装了 libyaml 0.1.3。

现在,当我将database.yml放在这样的rails项目中时:

defaults: &defaults
  adapter: mysql
  encoding: UTF-8
  username: root
  password:
  host: localhost
  engine: InnoDB

test:
  <<: *defaults
  database: my_app_test

在控制台中,

YAML.load_file("config/database.yml") 

结果是:

{"test" => {"apapter" => "mysql"...}}

问题是缺少“database”键。似乎没有将默认节点和测试节点合并在一起,而是只是复制默认节点。

有什么想法吗?

I used rvm upgrading to 1.9.2-p180. during the installation, libyaml 0.1.3 was fetched and installed.

Now when I have my database.yml in a rails project like this:

defaults: &defaults
  adapter: mysql
  encoding: UTF-8
  username: root
  password:
  host: localhost
  engine: InnoDB

test:
  <<: *defaults
  database: my_app_test

in console,

YAML.load_file("config/database.yml") 

The result is:

{"test" => {"apapter" => "mysql"...}}

The problem is the "database" key is missing. it seems not to merge the defaults node and test node togther, rather it just copy the default node.

any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南汐寒笙箫 2024-11-20 05:02:57

不管怎样,升级到 ruby​​-p290 解决了这个问题。

Anyway, upgrade to ruby-p290 solved the issue.

机场等船 2024-11-20 05:02:57

如果我理解正确,我无法复制它,也使用 1.9.2.180:(

irb(main):002:0> YAML::load_file('./test.yml')
=> {"defaults"=>{"adapter"=>"mysql", "encoding"=>"UTF-8", "username"=>"root", "password"=>nil, "host"=>"localhost", "engine"=>"InnoDB"}, "test"=>{"adapter"=>"mysql", "encoding"=>"UTF-8", "username"=>"root", "password"=>nil, "host"=>"localhost", "engine"=>"InnoDB", "database"=>"my_app_test"}}

向右滚动查看: "database"=>"my_app_test"}}

不确定这是否是如此回答,但我无法将代码放在评论中。如果我有错误的一端,我会编辑或删除......

If I understand you correctly, I can't duplicate that, also using 1.9.2.180:

irb(main):002:0> YAML::load_file('./test.yml')
=> {"defaults"=>{"adapter"=>"mysql", "encoding"=>"UTF-8", "username"=>"root", "password"=>nil, "host"=>"localhost", "engine"=>"InnoDB"}, "test"=>{"adapter"=>"mysql", "encoding"=>"UTF-8", "username"=>"root", "password"=>nil, "host"=>"localhost", "engine"=>"InnoDB", "database"=>"my_app_test"}}

(Scroll right to see: "database"=>"my_app_test"}} )

Not sure if this is an answer as such, but I couldn't put the code in a comment. If I have the wrong end of the stick I'll edit or delete...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文