在我的InvoicesController
我有这个:
def index
@invoices = current_user.invoices
respond_to do |format|
format.html
format.xls
format.csv # not working!
end
end
在我index.html.erb
看来,我有这两个下载链接:
<%= link_to "Download as Excel", invoices_path(:format => "xsl") %>
<%= link_to "Download as CSV", invoices_path(:format => "csv") %>
模板index.xsl.erb
也index.csv.erb
确实存在。
第一个链接有效,即 Excel 文件被下载到用户的计算机上。但是,CSV 文件在浏览器中呈现,而不是下载。
我必须怎么做才能使用户也能够下载 CSV 文件?
谢谢你的帮助。