我正在尝试将我的应用程序推送到heroku,但是没有通过

时间:2019-07-05 00:47:55

标签: ruby-on-rails heroku-postgres

新手在这里。我正在尝试将我的应用程序推送到heroku,下载postgres并从我的gemfile中删除了gem'sqlite3'。我需要更新我的database.yml,并且不知道在“ my_database_development”前面放什么?这是我的问题。我如何设置

这是我的代码

default: &default
  adapter: postgresql
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 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


我正在努力实现以下目标

development:
  adapter: postgresql
  database: my_database_development
  pool: 5
  timeout: 5000
test:
  adapter: postgresql
  database: my_database_test
  pool: 5
  timeout: 5000

production:
  adapter: postgresql
  database: my_database_production
  pool: 5
  timeout: 5000


这是我关注的链接

https://devcenter.heroku.com/articles/sqlite3#getting-a-sqlite-error-even-though-it-is-not-in-the-gemfile

终端错误

remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !     Detected sqlite3 gem which is not supported on Heroku:
remote:  !     https://devcenter.heroku.com/articles/sqlite3
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to orouge.
remote: 
To https://git.heroku.com/orouge.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/orouge.git'

2 个答案:

答案 0 :(得分:0)

您所拥有的代码仍在引用sqlite

  database: db/production.sqlite3

使用您拥有的另一个块。另外,在您的sqlite中可能引用了Gemfile.lock,但是我认为部署时它会被覆盖。

这是到database.yml文件示例的链接,使您的文件看起来像Postgres的文件。

https://gist.github.com/jwo/4512764

答案 1 :(得分:0)

在将postgres添加到gemfile中时,就会发生这种情况,但是您要么:

  1. 未从gemfile中删除sqlite3
  2. 添加postgres并删除sqlite3后,您尚未运行bundle install