Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.1 + Heroku Cedar - Static image assets are not being served

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.

like image 503
Denny Avatar asked Jun 23 '11 18:06

Denny


2 Answers

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.

like image 76
Christian Fazzini Avatar answered Nov 09 '22 16:11

Christian Fazzini


I had the same problem. changing production.rb file configuration to

config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'

from

config.action_dispatch.x_sendfile_header = "X-Sendfile"

worked for me. since Heroku uses nginx in front.

like image 31
Sunit Parekh Avatar answered Nov 09 '22 14:11

Sunit Parekh