DEV Community

Cover image for Deploy a Ruby on Rails application to Heroku using Redis
Ajeet Singh Raina for Redis

Posted on • Edited on

Deploy a Ruby on Rails application to Heroku using Redis

Heroku is a popular PaaS offering that allows software developers to easily deploy their code without worrying about the underlying infrastructure. By using a simple 'git push heroku' command, developers are able to deploy their application flawlessly. This platform offers support for a wide range of programming languages such as Java, Ruby, PHP, Node.js, Python, Scala, and Clojure.

Here's a quickstart guide to deploy Ruby apps on Heroku using Redis. We will be deploying a sample Leaderboard app and will be using company valuation and stock tickers as its domain.

Step 1. Create a Free Redis Enterprise Cloud account

Image6

Create your free Redis Enterprise Cloud account by visiting this link. Use Coupon code MATRIX200 and get $200 free credit for using Redis Enterprise Cloud.

Image1

Follow this link to create a Redis Enterprise Cloud subscription and database as shown below:

Image25

The database endpoint URL is unique for all and hence might be different in your case. Save it for future reference.

Step 2. Create a Heroku account

If you are using Heroku for the first time, create your new Heroku account through this link.

Image2

Step 3. Install the Heroku CLI on your system



    brew install heroku


Enter fullscreen mode Exit fullscreen mode

Step 4. Login to Heroku



    heroku login
    heroku: Press any key to open up the browser to login or q to exit:
    Opening browser to https://cli-auth.heroku.com/auth/cli/browser/XXXXXXXXXXA
    Logging in... done
    Logged in as your_email_address


Enter fullscreen mode Exit fullscreen mode

Step 5. Connect your application to Redis Enterprise Cloud

For this demonstration, we will be using a Sample Redis Leaderboard app.

Clone the repository



    git clone https://github.com/redis-developer/basic-redis-leaderboard-demo-ruby


Enter fullscreen mode Exit fullscreen mode

Run the commands below to get a functioning Git repository that contains a simple application as well as a app.json file.



heroku create
Creating app... done, ⬢ thawing-shore-07338
https://thawing-shore-07338.herokuapp.com/ | https://git.heroku.com/thawing-shore-07338.git


Enter fullscreen mode Exit fullscreen mode

Step 6. Setting up Environment Variables

Go to the Heroku dashboard, click "Settings" and set REDIS_HOST and REDIS_PASSWORD under the Config Vars.
Refer to Step 1 for the correct values to use.

Image3

You now have a functioning Git repository that contains a simple application as well as a app.json file, which is used by Node’s dependency manager.

Step 7. Deploy your code



$ git push heroku


Enter fullscreen mode Exit fullscreen mode

Wait for few seconds and you will see the messages below:



remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote: Default types for buildpack -> console, rake, web
remote:
remote: -----> Compressing...
remote: Done: 125.9M
remote: -----> Launching...
remote: Released v10
remote: https://thawing-shore-07338.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/thawing-shore-07338.git

  • [new branch] master -> master
Enter fullscreen mode Exit fullscreen mode




Step 8. Accessing the application

Open https://thawing-shore-07338.herokuapp.com/ to access your application on the browser.
Please note that the Web URL is unique, hence it will be different in your case.

Image4

How does it work?

Click here to read the complete blog.

Have queries? Reach out to me over Twitter

Top comments (0)