我正在构建一个小应用程序,它在本地工作.然后,当我在Heroku上部署它时,我的终端中出现了这个错误:
remote: An error occurred while installing sqlite3 (1.3.11), and Bundler cannot remote: continue. remote: Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling. remote: ! remote: ! Failed to install gems via Bundler. remote: ! remote: ! Detected sqlite3 gem which is not supported on Heroku. remote: ! https://devcenter.heroku.com/articles/sqlite3 remote: ! remote: remote: ! Push rejected, failed to compile Ruby app remote: remote: Verifying deploy... remote: remote: ! Push rejected to pockettheskimm. remote: To https://git.heroku.com/pockettheskimm.git ! [remote rejected] master -> master (pre-receive hook declined)
我随后阅读了关于Heroku的文档,它告诉我必须在我的应用程序中使用Postgres而不是sqlite3.所以我更新了我的应用程序,为Postgres交换了sqlite3:
default: &default adapter: postgresql pool: 5 timeout: 5000 development: <<: *default database: db/development.postgresql # 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.postgresql production: <<: *default database: db/production.postgresql
但现在当我在本地运行应用程序时,我在浏览器中收到此错误:
ActiveRecord::NoDatabaseError FATAL: database "db/development.postgresql" does not exist Extracted source (around line #661): 659 660 661 662 663 664 rescue ::PG::Error => error if error.message.include?("does not exist") raise ActiveRecord::NoDatabaseError.new(error.message, error) else raise end
我该怎么做才能解决这个问题?
这是对我有用的答案:
" rake db:create && rake db:migrate
在更改database.yml配置文件后,您是否继续进行开发?"
归功于/sf/ask/17360801/