Skip to content

Instantly share code, notes, and snippets.

@pjbelo
Last active October 17, 2018 17:20
Show Gist options
  • Save pjbelo/ee2eb0b80de2a5a97fc0f0e323f793ec to your computer and use it in GitHub Desktop.
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/`
# 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