database.yml和引用不起作用 [英] database.yml &references not working

查看:99
本文介绍了database.yml和引用不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们刚刚将虚拟机升级到我认为是相同的ruby配置(通过RVM ... Ruby 1.9.2,Rails 3.0.7,DataMapper 1.1.0)。最大的区别是我们从MySQL 5.0升级到5.1。

We just upgraded our virtual machines to what I thought was an identical ruby configuration (via RVM... Ruby 1.9.2, Rails 3.0.7, DataMapper 1.1.0). The biggest difference was that we went from MySQL 5.0 to 5.1.

由于某些原因,在旧VM上运行的完全相同的code / database.yml现在无法运行

For some reason, the exact same code/database.yml that was working on our old VMs now fails on our new ones at the point it tries to connect to the database.

问题在于此YAML:

mysql_defaults: &mysql_defaults
  adapter: mysql
  encoding: UTF-8
  username: user
  password: pass
  host: localhost

development:
  <<: *mysql_defaults
  database: devdb

production:
  <<: *mysql_defaults
  database: productiondb
  host: master.db.site.com

只是扩展到:

  "mysql_defaults" => {
    "adapter"=>"mysql",
    "encoding"=>"UTF-8",
    "username"=>"user",
    "password"=>"pass",
    "host"=>"localhost"
  },
  "development" => {
    "adapter"=>"mysql",
    "encoding"=>"UTF-8",
    "username"=>"user",
    "password"=>"pass",
    "host"=>"localhost"
  },
  "production" => {
    "adapter"=>"mysql",
    "encoding"=>"UTF-8",
    "username"=>"user",
    "password"=>"pass",
    "host"=>"localhost"
  }

而不是:

  "mysql_defaults" => {
    "adapter"=>"mysql",
    "encoding"=>"UTF-8",
    "username"=>"user",
    "password"=>"pass",
    "host"=>"localhost"
  },
  "development" => {
    "adapter"=>"mysql",
    "encoding"=>"UTF-8",
    "username"=>"user",
    "password"=>"pass",
    "host"=>"localhost",
    "database"=>"devdb"
  },
  "production" => {
    "adapter"=>"mysql",
    "encoding"=>"UTF-8",
    "username"=>"user",
    "password"=>"pass",
    "host"=>"master.db.site.com",
    "database"=>"productiondb"
  }

有人曾经历过吗?

根据Gemfile。锁(出于理智的考虑,我删除了它并再次运行捆绑安装),所有已安装的依赖项都相同(即Gemfile.lock在新旧设置之间没有区别)。

According to Gemfile.lock (I deleted it and ran bundle install again, just for sanity's sake), all the installed dependencies are the same (i.e. the Gemfile.lock does not diff between the old and the new setup). Nor does the database.yml.

推荐答案

Psych是新的YAML解析器,它可能更好,但不能合并哈希键。

Psych is the new YAML parser which is presumably better but can't merge hash keys.

这应该有助于
http://pivotallabs.com/users/mkocher/blog/articles/1692-yaml-psych-and-ruby-1-9- 2-p180-这里有龙

这篇关于database.yml和引用不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆