Search code examples
elasticsearchherokutirecedarbonsai-elasticsearch

How do I get Rails 3.1 with ElasticSearch & Tire working on Heroku Cedar Stack?


I'm having trouble getting Tire working using ElasticSearch with the Bonsai addon on the Heroku Cedar stack. It keeps crashing my app and when I check the Heroku logs (i.e. run heroku logs in Terminal), I Errno::ECONNREFUSED (Connection refused - connect(2)).

The setup works fine on my localhost. I've been all through the Elastic search resources and haven't found a fix yet.

Can anyone provide some assistance or guidance?


Solution

  • I finally found it... Through an obscure link on the Heroku Bonsai helps. I did this and it worked: Configuring Tire to use the Bonsai ElasticSearch Heroku add-on

    Here's a little more clarification on what I did to fix it.. In config/initializers/bonsai.rb:

      if ENV['BONSAI_INDEX_URL']
       Tire.configure do
        url "http://index.bonsai.io"
       end
       BONSAI_INDEX_NAME = ENV['BONSAI_INDEX_URL'][/[^\/]+$/]
      else
        app_name = Rails.application.class.parent_name.underscore.dasherize
        app_env = Rails.env
        BONSAI_INDEX_NAME = "#{app_name}-#{app_env}"
      end