ruby 2.6.5 rails 6.0.0 mysql 5.6
The background image that was displayed without problems in the local environment was not displayed in the production environment (heroku).
config/environments/production.rb
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
From
config/environments/production.rb
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
change to Reference article → https://qiita.com/__xxx/items/fa15f358beba2b9389da
However, the expected behavior did not work.
Most of the other articles tend to behave well in production with this content, but I didn't.
I found a slightly old article in 2015 → https://www.cotegg.com/blog/?p=189 Try out.
① Change from css to scss
② Also change the contents of scss
main.css
.main {
display: flex;
background-image: url("../main-bg.png "); /*Specify the URL of the image*/
background-size:cover;
background-repeat: no-repeat;
background-attachment: fixed;
}
From
main.scss
.main {
display: flex;
background-image: image-url("main-bg.png "); /*Change the description here*/
background-size:cover;
background-repeat: no-repeat;
background-attachment: fixed;
}
change to Confirm that there are no problems in the local environment
③ Precompile
% bundle exec rake assets:precompile RAILS_ENV=production
Don't forget to commit here and push to production.
% git push heroku master
Check the behavior in the production environment.
It went well.
Recommended Posts