Deploy a Ruby on Rails application to Heroku using Redis
Published: 2022-01-28 12:47:39

[Heroku](https://heroku.com) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hz5rqcgbpokxjnuu1pp0.png)
 

Create your free Redis Enterprise Cloud account [by visiting this link](https://redis.com/try-free). Use Coupon code MATRIX200 and get $200 free credit for using Redis Enterprise Cloud.

![Image1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ce3gsieo96f1ghrqk9zc.png)


[Follow this link](https://developer.redis.com/create/rediscloud) to create a Redis Enterprise Cloud subscription and database as shown below:

![Image25](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fbx0o2vh0nz7p1rq86eb.png)
 

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](https://signup.heroku.com/login).

![Image2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gux3vr2firln6zxnpv26.png)


### Step 3. Install the Heroku CLI on your system

   ```macos
    brew install heroku
   ```

### Step 4. Login to Heroku

   ```bash
    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
   ```

### Step 5. Connect your application to Redis Enterprise Cloud

For this demonstration, we will be using a [Sample Redis Leaderboard app](https://github.com/redis-developer/basic-redis-leaderboard-demo-ruby).

#### Clone the repository

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



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
```



### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2tjgvb2jwnqtu9lduvl.png)
 



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
```

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
```

### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e31jp3upvwswzo3w90om.png)
 

### How does it work?

[Click here to read the complete blog](https://developer.redis.com/create/heroku/herokuruby#how-does-it-work).

Have queries? Reach out to me over [Twitter](https://twitter.com/ajeetsraina)