我正在构建一个小应用程序,它在本地工作。然后,当我在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)
我随后read the documentation on 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
我该怎么做才能解决这个问题?
答案 0 :(得分:6)
这是对我有用的答案:
&#34;在您更改database.yml配置文件后,您是否在开发中运行rake db:create && rake db:migrate
? &#34;
答案 1 :(得分:0)
找到将sqlite3
作为依赖关系的gem,并将其从Gemfile
中移除。完成此操作后bundle install
并确保sqlite3
不再存在在Gemfile.lock
答案 2 :(得分:0)
这对我有用:
rails db:create
rails db:migrate
答案 3 :(得分:0)
尝试不使用 任何东西 在您的gem文件中,直到一切进行完毕 除此以外 ActiveRecord的功能将有所不同
答案 4 :(得分:-1)
某些初始化程序应该在创建数据库之前就使用它,因此db:create
会中断。
要解决根本原因中的错误,请修复初始化程序和您的lib设置。
ps:就我而言,它是FactoryBot。