[Ruby] [Beginner] Setting environment variables -dotenv-rails-

less than 1 minute read

What are environment variables?

Environment variables are like boxes for information that you can’t upload to Github. This allows you to write passwords directly in the application, By passing data from the OS, you can run the application without worrying about information leakage.

Setting method

Install gem


$ bundle install

#####.env file creation In the root directory where the Gemfile is located create .env file

Create environment variable
KEY='*******' # Enter the key or password you want to use

When calling


Then you can call it.

Exclude from Git management



If you forget this, information will be leaked, so be sure to set it.