1

我正在尝试将我的数据库环境设置为,staging但出现此错误:

$ bin/rails db:environment:set RAILS_ENV=staging
rails aborted!
ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter
/Users/bfruitman/workspace/hired/config/environment.rb:5:in `<top (required)>'
/Users/bfruitman/workspace/hired/bin/rails:9:in `<top (required)>'
/Users/bfruitman/workspace/hired/bin/spring:14:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:environment:set => environment
(See full trace by running task with --trace)

我已经有一个条目database.yml

staging:
  <<: *heroku

但这显然还不够好。我应该在哪里定义staging

4

2 回答 2

1

更改数据库环境的最佳方法是使用 psql:

update ar_internal_metadata set value = 'staging' where key = 'environment';

替换staging为您要使用的任何环境。

于 2017-05-02T03:30:14.407 回答
-2

您可能需要添加文件:config/environments/staging.rb,默认情况下不包含它,我通常首先复制我的 production.rb,然后进行任何暂存特定更改(如果需要)。

cp config/environments/production.rb config/environments/staging.rb

于 2017-04-29T00:20:34.263 回答