Hiding my API keys
07 Jan 2015Problem:
I don't want to expose API secret keys, but I still want to be able to commit my changes and push to github.
Solution:
- Install figaro gem
- set environment variables in config/application.yml
my_api_key: 'weoi23urow234jerow67jerjerjwejr'
- make sure .gitignore ignores config/application.yml
- in the initializer code, (for my week3 app, I put this in config/initializer/twitter.rb) use ENV['my_api_key'] instead of hardcoding the api key
- after deploying to heroku, run this command to set heroku's env variables
figaro heroku:set -e production