Downloading files from Ruby on Rails

Posted Almost 13 years ago. Visible to the public.

To offer files for download, use send_file.

def download(file)
  send_file file.path, :disposition => 'attachment'
end

Note that a send_file replaces the default :render action.

Dominik Schöler
Last edit
Almost 2 years ago
Daniel Straßner
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2011-07-26 18:19)