Downloading files from Ruby on Rails

Updated . Posted . 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.

Profile picture of Dominik Schöler
Dominik Schöler
Last edit
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)