創建下載鏈接的最佳方式是什麼?有沒有比以下更好的方法?如何創建下載鏈接
我想在視圖中使用link_to "Download", :controller => ..., :action => ...", :id => ...
。
添加match /documents/download/:id => documents#download
到routes.rb中
和Controller:
def download
send_file ...
end
而且,我想,如果可能的話,爲用戶保持在同一頁面的鏈接。
謝謝。
您發送的文件非常大或動態生成嗎? – dwhalen 2011-05-19 19:22:01
@Danny Rockets:是的,這些文件是動態生成的。 – tendans6 2011-05-19 19:26:13
http://stackoverflow.com/questions/6392003/how-to-download-a-file-from-rails-application – sybind 2013-08-31 06:01:50