Rails 5.2 Credentials + Heroku

Written on September 24, 2018

In Rails 5.2 the way credentials are stored and used in an application changed. Previously, credentials or environment variables were not versioned, thus for every environment used to run the application would have to be given the variables separately. This was to prevent instances of environment variables leaking if the repo was public.

Starting in 5.2 and moving forward, credentials can now be stored in the application and versioned. Viget has a nice write up of how the new mechanism works and how to go about accessing, updating and using the credentials.

Specifically helpful was the section on how to go about setting up your credentials on Heroku. Which moving forward is super nice! All you have to do is provide the Heroku application with the master key and Heroku will read the credentials straight from the credentials.yml.enc file. I find this a lot more streamlined because you don’t have to spend time adding in and making sure Heroku has the latest credentials. You change it once in the application and it’s usable on the server.

Stay in touch

Thanks for reading this article. I'd love to stay in touch and share more tips on programming and side projects with you. Sign up and I'll send you my articles straight to your email, you'll also get a free copy of the light themed version of my Git cheat sheet.
Git cheat sheet preview image