Skip to content

Create .env file

t-matsumo edited this page May 6, 2018 · 5 revisions

For security and migratability, we use gem dotenv-rails.

So, create .env file in your project root (= directory where Gemfile is) as follows.

touch /PATH/TO/PROJECT/ROOT/.env

The file defines environment variables called by ENV['KEY'].

.env contains following key and value.

RAILS_DATABASE_USER='username'
RAILS_DATABASE_PASSWORD='password'

ADRESS='smtp.example.com'
DOMAIN='smtp.example.com'
USER_NAME='username@example.com'
PASSWORD='mail password'

Detail

  • RAILS_DATABASE_USER
    user name of database.

  • RAILS_DATABASE_PASSWORD
    password of database.

  • ADRESS (optional)
    smtp server name.

  • DOMAIN (optional)
    smtp server domain.

  • USER_NAME (optional)
    email address to send email.

  • PASSWORD (optional)
    email password.

example with gamil

ADRESS='smtp.gmail.com'
DOMAIN='smtp.gmail.com'
USER_NAME='____@gmail.com'
PASSWORD='app password (not gmail password)'