创建下载链接的最佳方式是什么?有没有比以下更好的方法?如何创建下载链接
我想在视图中使用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