Created
October 11, 2012 13:28
-
-
Save maxidr/3872271 to your computer and use it in GitHub Desktop.
Allows you to set environment variables in a YAML file at config/env.yml (from http://railswizard.org of intridea)
This file contains hidden or 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
# in config/env.yml | |
defaults: &defaults | |
ENV_YAML: true | |
development: | |
<<: *defaults | |
test: | |
<<: *defaults | |
production: | |
<<: *defaults |
This file contains hidden or 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
# in lib/env_yaml.rb | |
require 'yaml' | |
begin | |
env_yaml = YAML.load_file(File.dirname(__FILE__) + '/../config/env.yml') | |
if env_hash = env_yaml[ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'] | |
env_hash.each_pair do |k,v| | |
ENV[k] = v.to_s | |
end | |
end | |
rescue StandardError => e | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment