When enabling a Heroku add-on, such a Redis-to-go or MemCachier, the add-on automatically populates our configuration variables with the add-on credentials. They are able to do this because of the Heroku API. Configuration variables are a core part of any Heroku application. In this recipe, we'll learn how to manage them via the API.
Note
Be sure to read the Getting started with the Platform API gem recipe before attempting this recipe.
To begin, we can fire up a terminal and navigate to our heroku-api-examples
directory. Then, we can perform the following steps:
We'll be practicing in the console. Let's start it up now:
$ ruby console.rb
Let's take a look at the available commands for the config-vars endpoint by using Pry's
ls -m
command:$ ls -m heroku_api.config_var PlatformAPI::ConfigVar#methods: info update
We can use the
info
command to view all of the configuration variables for an application. This command will return the variables in a...