I've finally gotten elasticsearch to not crash my app on startup however it anytime I try to search the app crashes and adding a new record crashes the app (but the record does get added).
The error message I get is:
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'
I'm not sure what's up with URI::InvalidURIError (bad URI(is not URI?): http://heroku config:0):
I've gone through everything here, and I've looked at this on the URI error and my app is still crashing for the same reason.
My Bonsai.rb looks like: `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
My Professor.rb model has searchkick:
class Professor < ActiveRecord::Base
searchkick
belongs_to :user
has_many :reviews
Lastly my gemfile:
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'
This line is unnecessary:
uri = URI.parse(ENV['beech-6556653.us-east-1.bonsai.io'])
Especially because that ENV isn't assigned a value. You can see all of your app's environment variables with heroku config:get
in a terminal.