1

I use the Figaro gem to set env variables for my apps hosted on Heroku.

To set the required env variables on production I use this:

$ figaro heroku:set -e production

Can I do something similar for my local environment? Right now I'm manually calling export foo=bar for each variable.

Thanks in advance!

RobertJoseph
  • 7,968
  • 12
  • 68
  • 113

1 Answers1

2

Yes. Make sure you have it installed in your Gemfile:

gem 'figaro'
bundle install

Then run:

figaro:install

And it will generate an application.yml file.

Make sure you use add your environment variables under the respective environments:

development:
  my_env_var: "stuff"
test:
  my_env_var: "stuff"
Graham S.
  • 1,480
  • 1
  • 20
  • 28
  • And the variables will automatically get set when my app runs? – RobertJoseph Oct 29 '15 at 18:48
  • 1
    Yes. Just use ENV['my_env_var'] to access it. You may need to restart your server. A side note also, that it gets added to your `.gitignore` file, so it won't get pushed up with heroku or git when you make commits. – Graham S. Oct 29 '15 at 18:49