The image “...” cannot be displayed because it contains errors


#1

I have the following problem in my Rails 3 application:

When I go to the following URL: (I use Firefox)
http://www.myfamily.moroshko.com/assets/2/thumb
I got this error:
The image “http://www.myfamily.moroshko.com/assets/2/thumb” cannot be displayed because it contains errors.

The log file shows:
Started GET “/assets/2/thumb” for 110.174.88.80 at Fri Jul 01 20:11:35 -0700 2011
Processing by AssetsController#show as HTML
Parameters: {“id”=>“2”, “style”=>“thumb”}
[/home/misha_moroshko/myfamily.moroshko.com/public/images/thumb.jpg] found!
Sent file /home/misha_moroshko/myfamily.moroshko.com/public/images/thumb.jpg (0.2ms)
Completed 200 OK in 2ms

What could be the problem ?


#2

i don’t use rails, but I’d guess here:

Processing by AssetsController#show as HTML

you’re sending it with HTML headers?


#3

Yes. I use Rails “send_file()” method which uses by default the X-Sendfile header.[hr]
Replacing

config.action_dispatch.x_sendfile_header = “X-Sendfile”

with

config.action_dispatch.x_sendfile_header = “X-Accel-Redirect”

in config/environments/production.rb solved the problem!


#4

If you’re using nginx, yes. X-Sendfile is still correct for Apache, though.