0
0

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 3 years have passed since last update.

herokuにデプロイするもassets:precompile errorがでた。

Last updated at Posted at 2021-01-26

初めまして

現在、個人でアプリ制作をしておりherokuにデプロイした時に「assets:precompile error」が出たのでそれの解決した方法について共有したいと思います。
また、私はまだまだ初心者の為、至らない箇所があると思いますが、ご容赦ください。

「We’re sorry, but something went wrong.If you are the application owner check the logs for more information.」とデプロイ画面遷移後に出た表示

デプロイ後に、アプリを開いて上記のような画面が出て最初は「???」でしたが、言われた通りターミナル上でlogを確認しました!

heroku logs --tail

上記を入力することにより、どのようなことが起こったのかターミナル上に表示してくれます。

読んでいると
image.png

ActionView::Template::Error (The asset "motivate.jpeg" is not present in the asset pipeline)とでてました。

「motivate.jpegが存在しないよ」と怒られました。

また、asset pipline(アセットパイプライン)という言葉がキーになります。

このアセットパイプラインが本番環境(デプロイ後)では自動で処理されず、画像がうまく読み込めていなかったみたいです。

解決方法

config.environments.production.rb

config.assets.compile = false
↓へ変更
config.assets.compile = true

config.assets.compile = trueにすることにより自動的にコンパイルしてくれるようです。

最後に

この方法によって無事にデプロイ後正常に動作を行うことができました。
しかし、少し動作が重くなったように感じられました。
この解決法が絡んでる可能性もあるので、今後わかり次第また記事にまとめます!

ここまで読んでいただきありがとうございました!

0
0
2

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?