我目前正在浏览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 production
和git 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
答案 0 :(得分:0)
运行bundle install
,然后推送到heroku
省略--without production
,以便gemfile.lock可以使用gem pg
答案 1 :(得分:0)
我使用Windows系统时遇到了同样的错误。在Ubunto虚拟机上尝试过,出于某种原因,错误消失了,因为我能够