2016-12-30 32 views
0

Rails应用程序使用gem 'searchkick'Heroku的轨道使用Elasticsearch宝石:: LoadError sqlite3的问题

运行:

heroku addons:open bonsai 
heroku config:set ELASTICSEARCH_URL=`heroku config:get BONSAI_URL` 
heroku run rake searchkick:reindex CLASS=Product 

出现问题

rake aborted! 
Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). 

的Gemfile:

source 'https://rubygems.org' 
gem 'rails', '~> 5.0.0', '>= 5.0.0.1' 
gem 'puma', '~> 3.0' 
gem 'sass-rails', '~> 5.0' 
gem 'uglifier', '>= 1.3.0' 
gem 'coffee-rails', '~> 4.2' 
gem 'jquery-rails' 
gem 'turbolinks', '~> 5' 
gem 'jbuilder', '~> 2.5' 
group :development, :test do 
    gem 'byebug', platform: :mri 
end 

group :development do 
    gem 'web-console' 
    gem 'listen', '~> 3.0.5' 
    gem 'spring' 
    gem 'spring-watcher-listen', '~> 2.0.0' 
end 

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7' 
gem 'haml', '~> 4.0', '>= 4.0.7' 
gem 'devise', '~> 4.2' 
gem 'simple_form', '~> 3.3', '>= 3.3.1' 
gem 'paperclip', '~> 5.1' 
gem 'searchkick', '~> 1.4' 
gem 'will_paginate', '~> 3.1', '>= 3.1.5' 
gem 'will_paginate-bootstrap', '~> 1.0', '>= 1.0.1' 

group :development do 
    gem 'sqlite3' 
end 

group :production do 
    gem 'pg' 
end 

数据库。 yml:

default: &default 
     adapter: sqlite3 
     pool: 5 
     timeout: 5000 

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

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

型号:

article.rb 

class Article < ApplicationRecord 

    searchkick 
    has_many :comments, dependent: :destroy 
    belongs_to :user 
    belongs_to :node 
    has_attached_file :article_img, styles: { index_img: "300x300>", show_img: "100x100>" }, default_url: "/images/:style/missing.png" 
    validates_attachment_content_type :article_img, content_type: /\Aimage\/.*\z/ 
end 
发生数据库sqlite3的应该做的

回答

0

您使用sqlite3适配器,用于生产环境,但在Gemfile你提到要在生产中使用pg DATABSE和sqlite只有在发展。因此,您需要根据使用情况修复Gemfiledatabase.yml

+0

解决这个问题,运行'Heroku的运行rake searchkick:REINDEX CLASS = Product' –

+0

的Heroku不使用你的database.yml –

+0

是,改变databaseyml: –