Rails 3.1 + Heroku Cedar - 没有提供静态图像资源 [英] Rails 3.1 + Heroku Cedar - Static image assets are not being served

查看:102
本文介绍了Rails 3.1 + Heroku Cedar - 没有提供静态图像资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Heroku Cedar上部署了一个Rails 3.1应用程序。出于某种原因,我的静态图片资源未被投放:

  2011-06-23T18:14:13 + 00:00 app [web.1]:开始GET/assets/me_reminder-30f9d1dead32e12238888adbee4b92d3.pngfor 98.207.60.248 at 2011-06-23 18:14:13 +0000 
2011-06-23T18:14:13 + 00 :00 app [web.1]:Served asset /me_reminder-30f9d1dead32e12238888adbee4b92d3.png - 200 OK(0ms)(pid 1)
2011-06-23T18:14:13 + 00:00 app [web.1] :cache:[GET /assets/me_reminder-30f9d1dead32e12238888adbee4b92d3.png] miss,store
2011-06-23T18:14:13 + 00:00 heroku [router]:GET xxxx.herokuapp.com/assets/me_reminder- 30f9d1dead32e12238888adbee4b92d3.png dyno = web.1 queue = 0 wait = 0ms service = 35ms status = 200 bytes = 0



<正如你所看到的,它正在返回0字节的东西。不用说,没有图片显示。



然而,我所有的其他静态资产(css,javascripts)都是正确的。任何想法在这里可能是错误的吗?

顺便说一下,我有另一个在heroku上的Rails 3.1应用程序,它工作得很好,所以我不认为这是一个问题带链轮等

谢谢。

解决方案

一样的问题。在 config / environments / production.rb 文件中,评论:

  config .action_dispatch.x_sendfile_header =X-Sendfile

相反,请:

  config.action_dispatch.x_sendfile_header = nil#For Heroku 

这也是推荐的方法。如 Heroku文档中所述。



适用于我。


I have deployed a Rails 3.1 application on Heroku Cedar. For some reason my static image assets are not being served:

2011-06-23T18:14:13+00:00 app[web.1]: Started GET "/assets/me_reminder-30f9d1dead32e12238888adbee4b92d3.png" for 98.207.60.248 at 2011-06-23 18:14:13 +0000
2011-06-23T18:14:13+00:00 app[web.1]: Served asset /me_reminder-30f9d1dead32e12238888adbee4b92d3.png - 200 OK (0ms) (pid 1)
2011-06-23T18:14:13+00:00 app[web.1]: cache: [GET /assets/me_reminder-30f9d1dead32e12238888adbee4b92d3.png] miss, store
2011-06-23T18:14:13+00:00 heroku[router]: GET xxxx.herokuapp.com/assets/me_reminder-30f9d1dead32e12238888adbee4b92d3.png dyno=web.1 queue=0 wait=0ms service=35ms status=200 bytes=0

As you can see, it is returning something with 0 bytes. Needless to say, no image shows.

However, all my other static assets (css, javascripts) are being served correctly. Any idea what could be wrong here?

By the way, I have another Rails 3.1 app on heroku which is working just fine, so I don't think it's a problem with sprockets, etc.

Thank you.

解决方案

I had the same problem. In config/environments/production.rb file, comment:

config.action_dispatch.x_sendfile_header = "X-Sendfile"

And instead, have:

config.action_dispatch.x_sendfile_header = nil # For Heroku

This is also the recommended way of doing this. As suggested in the Heroku docs.

Works for me.

这篇关于Rails 3.1 + Heroku Cedar - 没有提供静态图像资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆