Rails: How to download a previously uploaded document?

I don't use Carrierwave but I guess it's similar to Paperclip.

Therefore you should be able to use something like this

 link_to 'Download file', user.file.url

This is assuming you have a user instantiated object from a Model with a 'file' carrierwave attribute. Replace this with your attribute name.


You can use the send_file method for this. Which could look like:

class MyController
  def download_file
    @model = MyModel.find(params[:id])
    send_file(@model.file.path,
          :filename => @model.file.name,
          :type => @model.file.content_type,
          :disposition => 'attachment',
          :url_based_filename => true)
  end
end

Check the apidock link for more examples.