Image showing as blank in Rails 3.1 on Production (Heroku)

陌路散爱 提交于 2019-12-01 04:03:09

Remove this line from production.rb:

config.action_dispatch.x_sendfile_header = "X-Sendfile"

You should also align the settings in your config files with those in section 9 of the pipeline guides.

Sendfile headers contain information for the upstream webserver of where to find the file (on the file system) to serve it. This removes the load from the backend (Rails/Sprockets). When sendfile is on the HTTP response contains no body (it is zero length) which is why you see nothing.

On heroku the nginx servers do not have access to the application filesystem, so this won't work.

See this note on the Heroku dev site re sendfile.

If you are using heroku, this document outlines the best options for using the pipeline effectively.

You need to do two things to resolve it. First, change these two lines from false to true in production.rb file.

      config.assets.compile = true
      config.assets.digest = true

Second, if you've syntax like this for your images

    background: url("imgo.jpg") 

Change it to

     background: image-url("image.jpg")

I hope it does your job.

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