Last active
October 17, 2018 17:20
-
-
Save pjbelo/ee2eb0b80de2a5a97fc0f0e323f793ec to your computer and use it in GitHub Desktop.
[Rails] Load environment variables from file `config/local_env.yml`. Place file in `config/initializers/`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loads environment variables from file config/local_env.yml | |
# access vars using ENV['VAR_NAME'] | |
env_file = File.join(Rails.root, 'config', 'local_env.yml') | |
if File.exists?(env_file) | |
YAML.load(File.open(env_file)).each do |key, value| | |
ENV[key.to_s] = value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment