19
16

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でRailsアプリをデプロイする時にCSSが反映されない場合の対処法

Last updated at Posted at 2018-03-14

RailsアプリをHerokuでデプロイするときにCSSが反映されない場合は下記をコマンドラインで実行します。

ステップ1 

$ RAILS_ENV=production rake assets:precompile

ステップ2 

$ git add -A

ステップ3 

$ git commit -m "コミットの理由" //コミットの理由は自由に変更してください

ステップ4 

$ git push

ステップ5 

$ git push heroku

background-imageがきちんと反映されない場合

bundle exec rake assets:precompileをコマンドラインで実行するという方法もよく見かけますが、この方法だとbackground-imageがなぜか反映されません。なので、上のステップ1〜5の方法を実行してください。

さらにbackground-imageをきちんと反映させる方法として、config/environments/production.rbに下記を加えるという方法もあります。

config.assets.compile = true
config.serve_static_assets = true
19
16
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
19
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?