[RUBY] [Environment variables] What are rails environment variables?

【goal】

Use environment variables to embed information in your application

【merit】

■ Information that you do not want to leak can be used in the application ■ Improved security ■ Can be used for various APIs

【Development environment】

■ Mac OS catalina ■ Ruby on Rails (5.2.4.2) ■ Virtual Box:6.1 ■ Vagrant: 2.2.7

【Implementation】

Install gem'dotenv-rails'

application.Gemfile


gem 'dotenv-rails'

mac.terminal


bundle install

Create ".env" directly under the app

Write in .env

In the application.env


#google omniauth 2.For 0
GOOGLE_APP_ID='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
GOOGLE_APP_SECRET='xxxxxxxxxxxxxxxxxxxxxxxxxx'

#Deployment settings
DB_USERNAME='xxxxxxxx'
DB_PASSWORD="xxxxxxxxx"
DB_HOST="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
DB_DATABASE="xxxxxxxxxx"

#Mail function implementation
USER_NAME="txxxxxxxxxxxx"
USER_PASSWORD="xxxxxxxxxxx"

that's all After that, increase the code depending on the service or application you want to use.

Recommended Posts

[Environment variables] What are rails environment variables?
[Rails] What are params?
[rails] What are Strong Parameters?
What are practically final variables?
When there are environment variables in Java tests
What I learned in Java (Part 2) What are variables?
Introduce dotenv to Docker + Rails to manage environment variables
Rails Docker environment construction
[Java Silver] What are class variables instance variables and local variables?
Rails6 development environment construction [Mac]
How to set environment variables when using Payjp with Rails
Rails engineer environment construction ruby2.7.1
What is Rails gem devise?
Rails6 (MySQL, Ubuntu environment, Cloud9)
Rails environment construction Rails5.2.1 ruby2.5.1 Catalina
What are command line arguments?
How to set and describe environment variables using Rails zsh
[Docker] Rails 5.2 environment construction with docker
What are Ruby class methods?
Windows10 Eclipse environment construction & what are you doing Fukahori August 2020
config.ru What are you doing?
[Rails / MySQL] Mac environment construction
What are mass assignment vulnerabilities?
What are Java metrics? _Memo_20200818
What is Rails Active Record?
[Rails] What was the error message?
Rails + MySQL environment construction with Docker
What I learned from studying Rails
Why are class variables needed? [Java]
Rails (postgeresql. Ubuntu environment), heroku deployment
Find out about environment variables (memo)
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Java array variables are reference types
Ruby on Rails 6.0 environment construction memo
[Ruby on Rails] What is Bcrypt?
Rails on Docker environment construction procedure
[Environment construction with Docker] Rails 6 & MySQL 8
[Rails 6] Customize Bootstrap in Rails + Bootstrap 5.0.0-alpha environment
Pass environment variables to docker container
Troublesome Rails environment construction flow [Windows 10]
What are the rules in JUnit?
Setting project environment variables in intelliJ
[Environment construction] Uninstall rails from local
[Rails] AWS EC2 instance environment construction
Java local variables are thread safe
[Java] What are overrides and overloads?
[Rails] Check the instance variables and local variables of the file you are browsing
How to apply Rails environment variables to Docker container (aws :: Sigv4 :: Errors solution)