Step 1 – Install elasticsearch in your Rails Application in Production
If you haven’t setup elasticsearch in your Rails application in development, this article tells you how to do so in Linux
Step 2 – Create the search indices on your Heroku production application
At the command prompt, type the following:
1 2 heroku run rails c production --app NAME_OF_MY_APP 3
If you’re running a staging environment, then you’d type *staging* instead of production. NAME_OF_MY_APP is the name of your Rails application running on Heroku.
Step 3 – Install the bonsai-elasticsearch-rails gem in your Gemfile and run bundle install
1 group :production do 2 gem ‘rails_12factor’ #this is a gem Heroku also asks you to have as part of your Gemfile 3 gem ‘bonsai-elasticsearch-rails’ 4 end 5
Now run bundle install at the command prompt.
Step 4 – Add the bonsai Heroku add-on to your application
At the command prompt type:
1 2 heroku addons:add bonsai 3
If everything has gone smoothly, you should see the BONSAI_URL envrionment variable when you type the following at the command prompt:
1 2 heroku config | grep BONSAI 3
The BONSAI_URL environment variable:
1 2 BONSAI_URL => http://ql9lsrn8:email@example.com/ 3
When I did this, I actually ran into an issue with the BONSAI_URL not being initialized. I ended up contacting customer support and according to their customer support team, I had run into an edge case and they had to do something on their end to fix it. But they had the solution turned around within 24 hours of my initial contact.
Now, your rails application should be up and running with elasticsearch.