Rails 3.1 + Heroku Cedar - 未提供静态图像资源

Den*_*nny 24 ruby-on-rails heroku

我在Heroku Cedar上部署了一个Rails 3.1应用程序.由于某些原因,我的静态图像资产没有被提供:

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
Run Code Online (Sandbox Code Playgroud)

如您所见,它返回0字节的内容.不用说,没有图像显示.

但是,我所有其他静态资产(css,javascripts)都正确提供.知道这里有什么不对吗?

顺便说一句,我在heroku上有另一个Rails 3.1应用程序,它运行得很好,所以我不认为这是链轮等问题.

谢谢.

Chr*_*ini 27

我有同样的问题.在config/environments/production.rb文件中,评论:

config.action_dispatch.x_sendfile_header = "X-Sendfile"
Run Code Online (Sandbox Code Playgroud)

相反,有:

config.action_dispatch.x_sendfile_header = nil # For Heroku
Run Code Online (Sandbox Code Playgroud)

这也是推荐的方法.正如Heroku文档中所建议的那样.

适合我.


小智 9

我有同样的问题.将production.rb文件配置更改为

config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
Run Code Online (Sandbox Code Playgroud)

config.action_dispatch.x_sendfile_header = "X-Sendfile"
Run Code Online (Sandbox Code Playgroud)

为我工作.因为Heroku在前面使用了nginx.


Luk*_*uke 0

如果我没记错的话,在资产管道中使用图像可能会出现一些意外的行为。public/为了避免这种情况,您可以像以前版本的 Rails 一样保留它们。

请参阅此处的讨论。