0

我目前正在浏览 Railstutorial 并在运行时不断出错heroku run rake db:migrate

我已经在网上搜索了几个小时 - 错误似乎很常见,但建议的解决方案似乎都没有任何区别,非常感谢您的帮助!

错误是

Connecting to database specified by DATABASE_URL
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)

我运行gem install activerecord-postgresql-adapter并更改了我的 gemfile,它现在看起来像这样:

group :development do
  gem 'rspec-rails', '2.6.1'
  gem 'sqlite3', '~> 1.3.0'
end

group :test do
  gem 'rspec-rails', '2.6.1'
  gem 'webrat', '0.7.1'
  gem 'sqlite3', '~> 1.3.0'
end

group :production do
   gem "pg"
end

提交后我跑bundle install --without productiongit push heroku

我的 database.yml 看起来像这样:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# 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:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000
4

2 回答 2

0

运行bundle install然后推送到heroku

省略,--without production所以你 gemfile.lock 可以用 gem pg 实现

于 2013-03-03T16:34:44.930 回答
0

我在使用 Windows 系统时遇到了同样的错误。在 Ubunto 虚拟机上尝试过,由于某种原因,错误消失了

于 2018-01-02T21:14:43.780 回答