我的应用是一个 Ruby Rack 应用。当我的 Heroku 应用程序启动时它中断了,因为
/app/config.ru:8:in `read': No such file or directory - config/database.yml (Errno::ENOENT)
为什么会这样?我知道 Heroku 是为了创建这个文件 https://devcenter.heroku.com/articles/cedar-migration
The database credentials will still be configured automatically: at slug compile time, a config/database.yml that parses the DATABASE_URL from the environment will be written into the app.
令人沮丧的是 https://devcenter.heroku.com/articles/ruby 的文档没有解释 database.yml
最佳答案
好的,首先 - heroku 不使用 database.yml 文件。默认情况下,Rails 应用会自动从 config/目录加载它。无需在 config.ru 中手动加载它。如果你想在 heroku PosgreSQL 中使用 - 只需添加附加组件。 Heroku 会做所有其他事情来链接您的应用程序和数据库。如果你想使用外部 MySQL 服务器,你应该使用 Amazon RDS 附加组件
heroku addons:add amazon_rds url=mysql2://user:pass@dbhost/dbname
这样你就可以使用任何数据库了。我通过 Amazon RDS 插件使用 GoDaddy mysql bases。
无论如何,问题在你的 config.ru 第 8 行类似
read 'config/database.yml'
删掉看看其他和heroku不冲突的方法
祝你好运
关于ruby - Heroku 上没有这样的文件 'config/database.yml',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12885453/