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

本番環境でapp/assets/images以下の画像が表示されなかった時の対処法

Posted at

ユーザー登録の際、アバターを設定しなかったユーザーのデフォルトアバター画像を
image_tag 'hoge.png'
で設定していたのですが、開発環境では画像表示されるのに本番環境では表示されなかった・・・泣

結論

production.rb
config.assets.compile = true

config/environments/pruduction.rb内の
config.assets.compile = false ⇨ trueへ変更したら表示されました!

背景

本番環境と開発環境では、プリコンパイルの手順が異なる。
通常本番環境ではアセットパイプラインを通る処理が自動実行されないので、
上記のように本番環境上でアセットパイプラインを自動で通るように設定を変更することで解決できる。

参考

RAILS GUIDE アセットパイプライン
Rails初学者がつまずきやすい「アセットパイプライン」

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?