Skip to content
Jeremy Polley edited this page Apr 21, 2020 · 1 revision
  1. Add this line to your Gemfile gem 'configurator', git: 'https://github.com/wildbit/configurator.git'
  2. Then do bundle install
  3. Run command like this encrypt_property_for_yaml encrypt [SECRET_PASSWORD] [CONTENT_TO_ENCRYPT]
  4. Running the command will give you an encrypted value like this ENC(Vzwj44IdZ07EqWQJXolocY3kQOr/UYD02otU/dgM9loVnA==)
  5. Now you can place the encrypted value in a config file like config/production.yaml:
username: igor
password: ENC(Vzwj44IdZ07EqWQJXolocY3kQOr/UYD02otU/dgM9loVnA==)
  1. Next you need to load the config files by doing this:
require 'configurator'

App.config.files_path = File.join(File.dirname(__FILE__), '../config')
App.config.load_all!
  1. Now you should be able to access the config values in code like this:
puts App.config.production.username # => igor
puts App.config.production.password # => decrypted_password
  1. Note: you must run your code using bundle exec in order for require 'configurator' to work

General information

Clone this wiki locally