Forum: Ruby on Rails Action to Render Image for Download

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mario G. (Guest)
on 2009-05-16 06:16
Hi,

I'm trying to set up an action that will send an image to the browser as
an attachment for download using paperclip.  Sadly, I keep getting
stuck.  Insead, I keep sending an empty image to the browser.  Anyone
have any luck or any ideas?

  def download_image
    art = Art.find(params[:id])
    send_file art.list_image.url(:original), :type =>
art.list_image_content_type, :disposition => 'attachment'
  end

Thanks so much.
Mario G. (Guest)
on 2009-05-16 10:50
I got it, with the help of a friend.

send_file art.list_image.path(:original), :type =>
art.list_image_content_type, :disposition => 'attachment', :filename =>
art.id
This topic is locked and can not be replied to.