我在做
rake db:migrate
新克隆的应用程序时遇到这个错误。
“开发”数据库未配置。可用:[“生产”]
所以看了报错后,我在做
RAILS_ENV=production rake db:migrate
但这也行不通。
我的
database.yml
有
production:
adapter: postgresql
encoding: unicode
database: test
pool: 5
username: admin
password: admin
port: 5433
请建议。
添加
development:
adapter: postgresql
encoding: unicode
database: test
pool: 5
username: admin
password: admin
port: 5433
host: localhost
到
database.yml
文件。
此外,如果您测试您的应用程序,您还需要
test
环境。
您的
database.yml
文件显示您只有为数据库操作配置的生产环境。您还需要为开发环境添加配置。
打开您的
database.yml
文件并添加开发环境的配置。
类似下面的内容就足够了(方括号中的内容将替换为您的实际值):
development:
adapter:[your adapter]
encoding: [your encoding]
database: [your database for development]
pool: [your pool]
username: [your database server username]
password: [your database server password]
port: [the port you're connecting on]
记得适当缩进你的 yaml 代码。