Image urls for Rails 4 + Less not including the hash

可紊 提交于 2019-12-06 03:37:44
Richard Peck

The "hash" is known as asset fingerprinting, and is a standard feature of the Rails asset pipeline, which means it should work if everything is done right :)

We've had experience of this before, and you're 90% of the way there with it

I'd recommend 2 fixes:


1. Use asset_url in your LESS:

body {
  background-image: asset_url("background.jpg");
}

2. Precompile your assets

#config/environments/production.rb
config.serve_static_assets = true

#cmd
rake assets:precompile RAILS_ENV=production

This should make your assets static, thus allowing your CSS to load them with no issues!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!