Attachment_fu and S3 -- cannot download file correctly

I don’t know why this isn’t working. If I download a word doc that I
uploaded, all I get is the S3 file path in the document. If I access
the s3 file path directly in my browser, it downloads the file
correctly.

Here is my controller method:

def download
@curriculum = @school.curriculums.find(params[:id])
send_data @curriculum.attachment.public_filename,
:filename => @curriculum.attachment.filename,
:type => @curriculum.attachment.content_type
end

view:

link_to curriculum.attachment.filename.split(’.’).first, :action =>
‘download’, :id => curriculum.id

The file is downloaded, but not the file content. Thanks for any help!

you are trying to call send_data which will send a string to the
browser, so you are just sending the string of the url. try this:

def download
@curriculum = @school.curriculums.find(params[:id])
redirect_to @curriculum.public_filename
end

That worked! Thanks a lot.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs