我似乎无法在任何地方找到这个问题的简单明确的答案!一切似乎都已过时或不完整!
我只是希望用户能够点击链接或按钮并下载文件(即公共文件夹中的某个位置)
我试过这个:
#view
<%= link_to "Raw blast output" ,:action => :download, :file_name => "public/data/02_blastout/#{@bl_file}" %>
#controller
def download
send_file "#{RAILS_ROOT}/#{params[:file_name]}"
end
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
No route matches {:action=>"download", :file_name=>"public/data/02_blastout/input0.fa_x_Glyma1aaunq.bl", :controller=>"cvits"}
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!!