I have an uploader which allows you to upload documents. What I want to do is trigger a download for the document when you view its show action. The url would be something like:
/documents/16
This document could be .txt, or .doc.
So far, my show action looks like this:
def show
@document = Document.find(params[:id])
respond_with(@document) do |format|
format.html do
render layout: false, text: @document.name
end
end
end
How would I go about achieving this?
Take a look at the send_data method:
So, I think in your case it should be something like this: