[英]How Heroku or Rails config a database?
我是Rails的新手。 我将我的玩具应用程序从cloud9推到了Heroku,尽管我的Heroku应用程序中来自Heroku工具带的database.yml如下所示,但我的Heroku应用程序正在使用PostgreSQL:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
我知道它使用的是PostgreSQL,因为我可以使用pgAdmin III远程访问数据库。
那么Heroku内部发生了什么?
使用Heroku时,Heroku服务器将注入自己的数据库yml文件(将使用数据库url)。 这就是为什么代码中的database.yml不起作用的原因。
您可以在这里阅读更多内容https://devcenter.heroku.com/articles/rails-database-connection-behavior
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.