-
Notifications
You must be signed in to change notification settings - Fork 2
Usage
Jeremy Polley edited this page Apr 21, 2020
·
1 revision
- Add this line to your Gemfile
gem 'configurator', git: 'https://github.com/wildbit/configurator.git'
- Then do
bundle install
- Run command like this
encrypt_property_for_yaml encrypt [SECRET_PASSWORD] [CONTENT_TO_ENCRYPT]
- Running the command will give you an encrypted value like this
ENC(Vzwj44IdZ07EqWQJXolocY3kQOr/UYD02otU/dgM9loVnA==)
- Now you can place the encrypted value in a config file like
config/production.yaml
:
username: igor
password: ENC(Vzwj44IdZ07EqWQJXolocY3kQOr/UYD02otU/dgM9loVnA==)
- 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!
- 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
- Note: you must run your code using
bundle exec
in order forrequire 'configurator'
to work