I created file upload using paperclip! File uploads as it is supposed to.
Than I added file download method like this:
def download
sample = Sample.find(params[:id])
send_file upload.sample.path,
:filename => upload.sample_file_name,
:type => upload.sample_content_type,
:disposition => 'attachment'
flash[:notice] = "Your file has been downloaded"
end
But I cant figure out, what should I put in my show action so that I would be able to download the file?
I got as far as this:
<td><%= @sample.upload_file_name =%></td>
<%= link_to 'Download', :action => :download, :path =>@sample.upload.url, :type => @sample.upload_content_type %>
But it shows error : Couldn’t find Sample with id=download
Can anyone help me?
Think you need to change your link_to to send the :id (that’s what the controller action is looking for with params[:id])
Soz Karlis was writing as you posted 😀