5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HerokuにHeroku Postgresを導入してアプリケーションを動かしてみる2

Last updated at Posted at 2018-10-15

前回のあらすじ

500番のエラーが出て動かない所。
今回はその問題を解決する。

ローカル環境で試してみる

まずローカル環境で正常に動作するかを検証する。

スクリーンショット 2018-10-13 10.57.45.png

ローカル環境で動かした所、「Undefined variable: items」の文字がitemsが宣言されていないからか?
とりあえずBoardControllerの変数がitemになっていたのでitemsに変更。

スクリーンショット 2018-10-14 18.16.43.png

とりあえずローカル環境では動いた。
しかしheroku側ではうごかない。。。なぜ。

スクリーンショット 2018-10-14 18.19.41.png

どうもこの記事によると.gitignoreが怪しいらしい。

[LaravelアプリケーションをHerokuにデプロイ後、謎のエラーに苦しんだ話]
(http://shigechi-64.hatenablog.com/entry/2018/01/08/195232)

編集してみたけどエラー。。。

スクリーンショット 2018-10-14 18.36.33.png

Herokuが更新されているか確認。

commnad
heroku run bash

見た所大丈夫そう。うーん。なにが原因なのか。

この記事によるとlaravel にデバッグモードがあるらしい。やってみよう。

[Laravel localhost works, but heroku gives 500 error]
(https://stackoverflow.com/questions/31665706/laravel-localhost-works-but-heroku-gives-500-error)

./config/app.php
/*
    |--------------------------------------------------------------------------
    | Application Debug Mode
    |--------------------------------------------------------------------------
    |
    | When your application is in debug mode, detailed error messages with
    | stack traces will be shown on every error that occurs within your
    | application. If disabled, a simple generic error page is shown.
    |
    */

    'debug' => env('APP_DEBUG', true),

おっ!エラー内容が出てきた。

スクリーンショット 2018-10-14 20.20.57.png

どうもControllerのat Model::all()でエラーが起きてるらしい。

単純にデフォルトの接続をpgsql(postgleSQL)に変更してあげればよかった見たい。

database.php
'default' => env('DB_CONNECTION', 'pgsql'),
スクリーンショット 2018-10-15 16.29.53.png

ひとまずトップページが見れたのでよかったよかった。

5
5
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
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?