I’m noticing a different behavior between development and production
environments when I use caches_action along with send_data.
I have a method:
@thePic = Picture.find(params[:id])
send_data(@thePic.image.data, :filename => @thePic.image.filename,
:type => @thePic.image.content_type, :disposition => “attachment”)
Which works fine; it returns an image as expected, which is downloaded
by the browser. When I add a declaration:
it continues to work fine in development, presumbably because it doesn’t
cache in development mode. When I switch to production mode, however,
this no longer causes the file to be downloaded to the desktop, but
rather it opens up in the browser as if it were a text file.
I am not using url mapping, so the “image” url is something like
localhost:3000/gallery/image/3 which may be part of the problem - the
browser may not “recognize” it as an image, even though I am passing in
content-type and filename and telling it it’s an attachment.
Can anyone offer any help or suggestions.