7
6

More than 3 years have passed since last update.

Heroku上で背景画像が表示されないけどなんなんこれ

Posted at

HerokuにpushしたRailsアプリケーションのassets background-imageが読み込まれない問題の解決方法

状況

  1. ローカルでRailsアプリケーションを作成
  2. Herokuにデプロイ
  3. heroku open
  4. ローカルで表示されていた背景画像が表示されない

解決策

結論、以下の方法で解決しました。

config/environments/production.rb

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false

上記の
config.assets.compile = false
を、
config.assets.compile = true
に修正

参考
https://qiita.com/pugiemonn/items/1663ca88766ceba6a397

その後、rails assets:precompile ~ git push heroku masterを実行

$ rails assets:precompile
$ git add .
$ git commit -m 'fix: config.assets.compile'
$ git push origin master
$ git push heroku master
$ heroku open

herokuアプリを確認してみてください。

参考
https://qiita.com/___xxx_/items/bb85d26d50ff3940441c

7
6
1

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