Created
February 17, 2021 23:05
-
-
Save nilsandrey/a8f933faa0a1fc8824156c523a916820 to your computer and use it in GitHub Desktop.
Ensure required environment variables are set when booting up Rails. https://boringrails.com/tips/ensure-rails-env-vars
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
# config/initializers/01_ensure_environment.rb | |
if Rails.env.development? | |
%w[ | |
AWS_ACCESS_KEY_ID | |
AWS_SECRET_ACCESS_KEY | |
S3_BUCKET | |
ALGOLIA_ID | |
ALGOLIA_API_KEY | |
ALGOLIA_SEARCH_KEY | |
ALGOLIA_INDEX | |
ALGOLIA_CAMPAIGN_INDEX | |
TWITTER_API_SECRET | |
TWITTER_API_TOKEN | |
].each do |env_var| | |
if !ENV.has_key?(env_var) || ENV[env_var].blank? | |
raise <<~EOL | |
Missing environment variable: #{env_var} | |
Ask a teammate for the appropriate value. | |
EOL | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment