导轨生产中的背景图像不起作用

rails 4(生产环境)中的背景图像不起作用。 在我看来,资产管道存在问题。 当我用css写的时候:

selector{ background-image: url(image.jpg) } 

它生成http://sofzh.miximages.com/javascript/image.jpg并且它不起作用。 如果我手动将URL更改为image.jpg-fingerprint(来自公共/资产),那么一切都还可以。

ckeditor也行不通。

这是我的production.rb

  config.cache_classes = true config.assets.enabled = true config.eager_load = true config.assets.precompile += Ckeditor.assets config.consider_all_requests_local = false config.action_controller.perform_caching = true config.assets.js_compressor = :uglifier config.assets.compile = false config.assets.digest = true config.assets.version = '1.0' config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' config.log_level = :info config.log_formatter = ::Logger::Formatter.new 

您没有使用资产管道 – 您没有使用文档的指纹缓存版本。 要使用资产管道,您需要使用指向文档的指纹缓存版本的新助手。 要做到这一点,要么在你的CSS中嵌入erb,要么使用sass。 我将在我的例子中使用sass:

不正确(不使用资产管道):

 .class background-image: url('image.jpg') 

正确(使用资产管道):

 .class background-image: image-url('image.jpg') 

进一步阅读: http : //guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets