Using credentials.yml with Rails and Heroku
Create credentials.yml and master key:
rails credentials:edit
Edit credentails:
EDITOR=vim rails credentials:edit
WORKING WITH VIM:
- For inserting
- Press i //Do required editing
- For exiting Press Esc
- :wq //for exiting and saving
- :q! //for exiting without saving
EXAMPLE OF HOW CREDENTIALS.YML can look:
development: github: client: acascascsacascascasc secret: vdsvsvg34g34gproduction: github: client: 34g3rvv secret: erberb43
FIND A CREDENTIAL:
rails cRails.application.credentials.dig(:aws, :access_key_id)
or if an env variable is used
Rails.application.credentials[Rails.env.to_sym][:aws][:access_key_id]
The credentials.yml file should NOT be in gitignore.
The master key that decrypts the credentials SHOULD be in gitignore.
To set your master key in production:
heroku config:set RAILS_MASTER_KEY=123456789
or
heroku config:set RAILS_MASTER_KEY=`cat config/master.key`
That's all you need to know about credentials in Ruby on Rails. Good luck :)