Help us understand the problem. What is going on with this article?

Rails 5 アプリのherokuへのデプロイ手順

環境

Rails 5.0.7.2
Ruby 2.6.3

herokuへのデプロイ手順

  1. heroku にアプリを作成(すでにherokuにログインしていると仮定)
    • $ heroku create herokuアプリ名
  2. 本番環境用にGemfile, database.ymlを変更
    • Gemfilm: Postgre SQLとRailsを連携させる
    • database.yml: DBをPostgreSQLに設定
  3. 下記を追加,実行し,本番環境へ反映
    • 本番環境上でアセットパイプラインを通るようにプリコンパイル処理を実行する
      • config/environments/production.rb config.assets.compile = false
    • 本番環境上でアセットパイプラインを自動で通るように設定を変更する
      • $ rake assets:precompile RAILS_ENV=production
      • 試したい場合は,以下コマンドを打ってエラーが出ないかを見てみる
        • $ RAILS_ENV=production bundle exec rake assets:precompile
  4. heroku にデプロイ
    • $ git push heroku master
  5. マイグレーション
    • $ heroku run rails db:migrate

詳細:本番環境用にGemfile, database.ymlを変更

group :production do
  gem 'pg', '0.21.0'
end
database.yml

production:
  adapter: postgresql
  encoding: unicode
  pool: 5
  database: message-board_production
  username: message-board
  password: <%= ENV['MESSAGE-BOARD_DATABASE_PASSWORD'] %>

まとめ

一番最初に(herokuへデプロイする前に)アセットパイプラインのための設定をしておきましょう.
私はこの順番をミスりました.

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away