我正在尝试将一个应用程序(只是 Rails 教程中的一个简单应用程序)部署到 Heroku,但它一直给我相同的错误消息。我使用命令:
git push heroku master
一开始好好的,然后突然出现这个错误:
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile.
我已经进行了捆绑安装,一切都很顺利。
这是我的 Gemfile:
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
也许我在 databse.yml 文件中遗漏了一些东西?
# 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
顺便说一句,我不知道这是否有帮助,但我使用的是 Rails 4.0.4、Ruby 2.1.1 和 Mac 上已安装的 SQLite 版本,即 3.7.13
最佳答案
Kirti 说得对,Heroku 不支持 sqlite 作为适配器,
执行以下操作
在 Gemfile 中:
group :production, :staging do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
在database.yml
production:
adapter: postgresql
database: name_of_your_db
pool: 5
timeout: 5000
关于ruby-on-rails - Gem::LoadError:尝试在 Heroku 上部署时 - Rails 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22941849/