更新时间:2023-02-24 14:17:35
一样的问题。在 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.