0

我的控制器:-

def download
    send_file( "/123.zip" )
  end

我的下载视图:-

<h1>Hello World</h1>

从我调用下载选项的地方:-

<%= link_to 'download', :class => "btn btn-large btn-danger" do %>

请帮助我如何制作该链接..现在这显示错误

Sent file /123.zip (1.0ms)
DEPRECATION WARNING: Passing a template handler in the template name is deprecated. You can simply remove the handler name or pass render :handlers => [:erb] instead. (called from c:in `find_template':)
  Rendered layouts/error/application.html.erb within layouts/application (0.0ms)
  Rendered layouts/_sidebar.html.erb (13.0ms)
Completed 404 Not Found in 60ms (Views: 50.0ms | ActiveRecord: 4.0ms)
4

1 回答 1

1

使您的链接像这样:-

<%= link_to 'download', "/PatientManagement/download", :class => "btn btn-large btn-danger"%>

在控制器中

send_file( "<absolute path to file/123.zip" )

您还可以使用 Rails.root 获取 Rails 根目录。

于 2013-08-21T07:44:36.337 回答