I want to set MONGOHQ_URL
in my sinatra app in order to be able to do this:
uri = URI.parse(ENV[开发者_运维知识库'MONGOHQ_URL'])
How do I setup the MONGOHQ_URL
?
- on Windows:
set MONGOHQ_URL=test
- on Unix (bash):
export MONGOHQ_URL=test
- on Unix (csh):
setenv MONGOHQ_URL test
In order for your environment variables to always be available to your app, you will need to make sure they get exported whenever a new terminal session launches. It's common to put these in .bashrc
for example
export MONGOHQ_URL=https://some.long.secure.url # for example
But for your local development purposes you might want to check out dotenv gem which allows you to store local environment variables in .env
file in root of your project. For production, you should be able to Figaro with Sinatra, for more see answer to this question or see readme on the github repo
In general you should always make sure not to commit sensitive config information in your codebase so make sure to add any files like .env
or config/application.yml
to your .gitignore
file.
精彩评论