Created
February 4, 2012 18:25
-
-
Save aitor/1739323 to your computer and use it in GitHub Desktop.
Rails 3.x initializer for loading HEROKU envs in local environment
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
| # Load heroku ENV variables in local development on Rails startup | |
| # | |
| # For a variable defined like this: | |
| # | |
| # heroku config:add S3_KEY='s3krit' | |
| # | |
| # This initializer will define a ENV["S3_KEY"] with a 's3krit' value in development environment. | |
| # Be careful to not overwrite any variable by mistake. | |
| # Potentially destructive. | |
| if Rails.env.development? | |
| require 'heroku/command/config' | |
| app_name = Rails.application.class.parent_name.downcase | |
| heroku_env = Heroku::Command::Base.new.heroku.config_vars(app_name) | |
| # Copy manually. Can't merge since ENV is not a real hash | |
| heroku_env.keys.each do |key| | |
| ENV[key]=heroku_env[key] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment