我终于得到了弹性搜索,以便在启动时不会崩溃我的应用程序,但是无论何时我尝试搜索应用程序崩溃并添加新记录都会导致应用程序崩溃(但记录确实会被添加)。
我得到的错误信息是:
Professor Store (0.9ms) {"id":59,"exception":["URI::InvalidURIError","bad URI(is not URI?): http://heroku config:0"]}
2016-09-12T16:48:34.008480+00:00 app[web.1]: Completed 500 Internal Server Error in 14ms (Searchkick: 0.9ms | ActiveRecord: 7.6ms | Elasticsearch: 0.0ms)
2016-09-12T16:48:34.009289+00:00 app[web.1]:
2016-09-12T16:48:34.009290+00:00 app[web.1]: URI::InvalidURIError (bad URI(is not URI?): http://heroku config:0):
2016-09-12T16:48:34.009291+00:00 app[web.1]: app/controllers/professors_controller.rb:51:in `block in create'
2016-09-12T16:48:34.009291+00:00 app[web.1]: app/controllers/professors_controller.rb:50:in `create'
我不确定URI::InvalidURIError (bad URI(is not URI?): http://heroku config:0):
的用途是什么
我已经浏览了所有内容here,并且我已经查看了这个on the URI error,我的应用仍然因为同样的原因而崩溃。
我的Bonsai.rb看起来像:`BONSAI_URL = ENV [' beech-6556653.us-east-1.bonsai.io']
if BONSAI_URL
uri = URI.parse(ENV['beech-6556653.us-east-1.bonsai.io'])
Searchkick.client = Elasticsearch::Client.new({
url:BONSAI_URL,
log: true
})
end
我的Professor.rb模型有搜索结果:
class Professor < ActiveRecord::Base
searchkick
belongs_to :user
has_many :reviews
最后我的宝石文件:
source 'https://rubygems.org'
ruby '2.3.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
#bcrypt for for encrpytion
gem 'bcrypt', '~> 3.1', '>= 3.1.11'
#byebug
gem 'byebug', '~> 9.0', '>= 9.0.5'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
#paperclip for easy upload management
gem 'paperclip', '~> 4.3', '>= 4.3.6'
#bootstrap-sass
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.6'
#searchkick
gem 'searchkick', '~> 1.2', '>= 1.2.1'
#paginate
gem 'will_paginate', '~> 3.1'
#paginate for bootstrap
gem 'bootstrap-will_paginate', '~> 0.0.10'
#rmagick
gem 'rmagick', '~> 2.15', '>= 2.15.4'
#Carrierwave
gem 'carrierwave'
#Cloudinary
gem 'cloudinary'
#Paperclip forcloudinary
gem 'paperclip-cloudinary'
答案 0 :(得分:1)
此行是不必要的:
uri = URI.parse(ENV['beech-6556653.us-east-1.bonsai.io'])
特别是因为没有为ENV分配值。您可以在终端中使用heroku config:get
查看所有应用的环境变量。