Gem :: LoadError:尝试在Heroku上部署时--Rails 4

时间:2014-04-08 15:43:52

标签: ruby-on-rails ruby sqlite heroku

我正在尝试将应用程序(只是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

2 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:2)

SQLite 不适合作为生产等级数据库。相反,Heroku提供生产级 PostgreSQL 数据库作为服务。

阅读详细信息 SQLite on Heroku