I have an app that I have launched to heroku. In my development environment my CSS background is loading fine. However, I cannot figure out why its not loading in my production environment.
body {
font-family: "Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
background: url('letters.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
I read a heroku article about adding to my application.rb file:
config.assets.initialize_on_precompile = true
However it said that I don't need to do this if I have this gem:
gem 'rails_12factor'
Is my syntax wrong or do I need to add some piece of code elsewhere?
You can use url(asset-path('letter.jpg'))
instead of url('letters.jpg')
And for it to work in heroku, you have to precompile your assets locally and push in heroku, to do that run $rake assets:precompile
and then push the generated assets file to heroku.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.