Skip to content

Commit

Permalink
Add dotenv-rails gem
Browse files Browse the repository at this point in the history
  • Loading branch information
taketo1113 committed Dec 10, 2024
1 parent deddb39 commit d88b9ea
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
20 changes: 20 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Usage .env
# SAMPLE_VAR=XXXXXX
#

# DB
SAY_DATABASE_USERNAME_DEV=
SAY_DATABASE_PASSWORD_DEV=
SAY_DATABASE_USERNAME=say
SAY_DATABASE_PASSWORD=
#SAY_DATABASE_HOSTNAME=

#MYSQL_SOCKET=/var/lib/mysql/mysql.sock
#REDIS_URL=

## for production env
# Secret
#SECRET_KEY_BASE=

# environments
RAILS_LOG_LEVEL=debug
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ vendor/bundle
# Ignore all environment files (except templates).
/.env*
!/.env*.erb

# config
config/database.yml
!/.env.example

# Ignore all logfiles and tempfiles.
/log/*
Expand Down
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ gem "mysql2", "~> 0.5"

gem "puma", ">= 5.0"

gem "slim-rails"
gem "jbuilder"
gem "dotenv-rails"

gem "sprockets-rails"
gem "jsbundling-rails"

gem "slim-rails"
gem "jbuilder"

gem "rack-cors"

# Use Redis adapter to run Action Cable in production
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ GEM
irb (~> 1.10)
reline (>= 0.3.8)
diff-lcs (1.5.1)
dotenv (3.1.4)
dotenv-rails (3.1.4)
dotenv (= 3.1.4)
railties (>= 6.1)
drb (2.2.1)
erubi (1.13.0)
factory_bot (6.5.0)
Expand Down Expand Up @@ -330,6 +334,7 @@ DEPENDENCIES
capybara
committee-rails
debug
dotenv-rails
factory_bot_rails
foreman
jbuilder
Expand Down
11 changes: 7 additions & 4 deletions config/database.yml.example → config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
socket: /tmp/mysql.sock
socket: <%= ENV['MYSQL_SOCKET'] %>

development:
<<: *default
database: say_development
username: <%= ENV['SAY_DATABASE_USERNAME_DEV'] %>
password: <%= ENV['SAY_DATABASE_PASSWORD_DEV'] %>

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: say_test
username: <%= ENV['SAY_DATABASE_USERNAME_DEV'] %>
password: <%= ENV['SAY_DATABASE_PASSWORD_DEV'] %>
host: <%= ENV['SAY_DATABASE_HOSTNAME'] %> # for CI

# As with config/credentials.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
Expand All @@ -51,5 +54,5 @@ test:
production:
<<: *default
database: say_production
username: say
username: <%= ENV['SAY_DATABASE_USERNAME'] %>
password: <%= ENV['SAY_DATABASE_PASSWORD'] %>

0 comments on commit d88b9ea

Please sign in to comment.