LoginSignup
0
0

More than 3 years have passed since last update.

Railsチュートリアル 5章最後でHerokuが動かなくなる

Posted at

Railsチュートリアルをもりもりとやっています。
5章に来て初めて本格的に躓いてしまったので、備忘録として記録します。

herokuが動かない・・・

5章の最後に'git push heroku'をしたところこの画面がでました。
スクリーンショット 2020-08-20 20.25.50.png

Application error
An error occurred in the application and your page could not be served. 
If you are thee application owner, check your logs for details. 
You can do this from the Heroku CLI with the command
heroku logs --tail

対処

ひとまず色々検索して以下のコマンドを打ちました。

heroku logs herokuのログの出力
見るべきポイント:errorと書かれている行

>>$ heroku logs #ログ出力
:
(中略) #errorと書かれている箇所を探す
:
2020-08-20T12:51:51.649616+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=enigmatic-harbor-30759.herokuapp.com request_id=6cf41616-a067-4dc6-8d2c-696895e1b968 fwd="60.76.208.83" dyno= connect= service= status=503 bytes= protocol=https
:

heroku run rails c railsでコンソールを起動する
見るべきポイント:エラーになっているファイル、エラー原因

>>$ heroku run rails c #コンソールの起動
:
(中略) #ファイル名が書かれている箇所を探す
:
4: from /app/app/helpers/application_helper_test.rb:1:in `<top (required)>'
: 
:#最終的なエラーを確認する
/app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require': No such file to load -- test_helper.rb (LoadError)

以上の内容でわかったこと
logを見る限りだと、よくわからない・・・
・console起動でみると、どうやらapplication_helper_test.rbが悪さをしている?
・上のファイルがtest_helper.rbを呼んでるけど、ファイルがないと言われている。

結論

application_helper_test.rbtest_helper.rbを参照できないようフォルダ構成になっていまいました。
本来であれば、testsフォルダ内にあるべきapplication_helper_test.rbファイルが別のフォルダ(app)に入っていたようです。
ひとまず、ファイルを移動させ、再度実行するとエラーがなくなりました。

感想

エラーが出た時の、ログの読み取りがうまく出来なかったのでてこずってしまいました・・・。改めて整理してみて、案外読み取るポイントってシンプルなんだなと改めておもいました。

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