I'm using the following tags in my html.erb to both display and download a jpg file that is not in the public/images folder:
<%= image_tag retrieve_photo_path(@photo) %>
<%= link_to "Download Photo", download_photo_path(@photo) %>
my controller code looks like:
def retrieve
@photo = Photo.find(params[:id])
send_data File.read(@photo.abs_filepath), :type = "image/jpeg", :disposition => "inline"
end
def download
@photo = Photo.find(params[:id])
send_file @photo.abs_filepath, :type = "image/jpeg", :filename => @photo.filename
end
The download link works perfectly, but the image tag displays a red x (broken image). What am I missing? I'm using InstantRails on WinXP, updated to Rails 2.3.4 and Ruby 1.8.6.