使用sqlite3 gem

时间:2018-03-31 19:33:22

标签: ruby-on-rails heroku rubygems

我正在尝试将我的应用部署到Heroku,但它失败了。我得到以下错误

  

无法通过Bundler安装gem。   远程:!检测到Heroku不支持的sqlite3 gem:   远程:! https://devcenter.heroku.com/articles/sqlite3   远程:!   远程:!推送拒绝,无法编译Ruby应用程序。

这是我的Gemfile

source 'https://rubygems.org'

gem 'rails', '4.2.5'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
#Authentication Gem -> https://github.com/thoughtbot/clearance
gem 'clearance', '~> 1.16.1'
gem 'bootstrap'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
#Gem for search
#https://github.com/karmi/retire
gem 'tire'
gem 'simple_form', '~> 3.4'
gem 'jquery-turbolinks'
gem "chartkick"

group :development, :test do
  gem 'byebug'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

2 个答案:

答案 0 :(得分:1)

Heroku不支持sqlite3,您可以使用Postgresql。

仅为开发添加sqlite3

group :development do
   gem 'sqlite3'
end

group :test, :production do
    gem 'pg'
end

然后在提交更改之前运行bundle install命令。

答案 1 :(得分:0)

Ganesh让你离开了...除了更新你的gemfile之外,你还想编辑你的config/database.yml

Gemfile =>

group :development, :test do
   gem 'sqlite3'
end

group :production do
    gem 'pg'
end

config / database.yml =>

default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test:
  <<: *default
  database: db/test.sqlite3

production:
  adapter: postgresql
  encoding: unicode
  host: localhost 
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  database: sample_production
  username: sample
  password: <%= ENV['SAMPLE_DATABASE_PASSWORD'] %>

其中SAMPLE通常是您应用的名称......