LoginSignup
0
1

More than 3 years have passed since last update.

【Cloud9】ローカル環境はSQLite、本番はPostgreSQLにする設定

Last updated at Posted at 2019-07-31

開発環境をCloud9で本番環境をHerokuにする場合に、ローカル環境はSQLite、本番はPostgreSQLにする設定方法です。

Gemfileの設定

sqlite3をコメントアウト

Gemfile.
#gem 'sqlite3', '~> 1.3.6'

group :development, :test doに1行追記する

Gemfile.
group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
  gem 'sqlite3', '~> 1.3.6'  #←追記する1行
end

group :production doを丸ごと追加

Gemfile.
group :production do
  gem 'pg'
end

bundle installを実行

without puroductionはPosgreSQL がローカルにないために付ける
アプリケーションルートから実行した

ターミナル.
$bundle install --without production

database.ymlの設定変更

config/database.yml-変更後
production:
#半角スペース2個分の空白を開ける
  <<: *default
  adapter: postgresql
  encoding: unicode
  pool: 5

config/environments/production.rbの設定

config/environments/production.rb
#デフォルトでfalseとなっている以下の箇所をtrueに変更
  config.assets.compile = true
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1