Environment variables are like boxes that hold information that can't be uploaded to Github. As a result, you do not have to write the password directly in the application. By passing data from the OS, you can run the application without worrying about information leakage.
Gemfile
gem 'dotenv-rails'
$ bundle install
In the root directory where the Gemfile is located Create an .env file
KEY='*******' #Enter the key and password you want to use
SECRET_KEY='*******'
When calling
ENV['KEY']
You can call it.
.gitignore
/.env
If you forget this, information will be leaked, so be sure to set it.
Recommended Posts