send_file无法正常工作 - Ruby on Rails

时间:2014-04-03 15:15:45

标签: ruby-on-rails ruby sendfile

我在这里有这个动作:

def download
 send_file 'C:/Sites/solver/public/test.zip'
end

当我从我的html执行它时,没有任何事情发生,也没有下载任何内容。

但这是它产生的日志:

Started POST "/ssh/download" for 127.0.0.1 at 2014-04-03 11:06:17 -0400
Processing by SshController#download as */*
Sent file C:/Sites/solver/public/test.zip (0.0ms)
Completed 200 OK in 5ms (ActiveRecord: 0.0ms)

任何人都可以帮助我理解缺少的东西吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

在您的视图中,添加download选项,例如:

link_to 'Download', download_path(id), download: "file"
相关问题