LoginSignup
1
0

More than 5 years have passed since last update.

herokuにデプロイできるが動かない〜PostgreSQL 1.0.0編〜

Last updated at Posted at 2018-04-23

Steps to reproduce

  1. Gemfileのproductionにgem "pg", "1.0.0"を追記
  2. bundle install
  3. git add .
  4. git commit
  5. git push heroku master
  6. Webアプリのトップページを開く

Expected behavior

ちゃんとWebアプリが動く

Actual behavior

アプリが動かず、

2018-04-23T02:16:05.027483+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/"

のような、なぜかクラッシュしていることだけがわかるログが現れる。

How to do to resolve

まず、何が起こっているか確認したい。
なので以下の手順でログを確認する。

  1. heroku run rails c
  2. Webアプリにアクセス

(参考:http://www.workabroad.jp/posts/2166)

すると

`rescue in spec': Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)

というように、postgresqlがうまく動いていないというエラーが見て取れる。
このエラーメッセージで検索すると、以下のページが見つかった。
https://github.com/rails/rails/issues/31673
回答にあったリンク先に向かうと、
https://github.com/rails/rails/issues/31669
とあり、現在のrailsではpostgresql 1.0.0はサポートされていないことがわかる。
なので、以下の手順で解決する。

  1. Gemfileのproductionのpgをgem "pg", "~> 0.21.0"に変更
  2. bundle install
  3. git add .
  4. git commit
  5. git push heroku master
  6. Webアプリのトップページを開く

無事に動きました。

1
0
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
1
0