相关疑难解决方法(0)

rails不会将send_data作为文件

我遇到了Rails方法的问题: send_data

这是我的行动:

def export
  send_data(current_user.contacts.to_csv,
    type: 'text/csv; charset=utf-8; header=present',
    disposition: 'attachment; filename=contacts.csv'
  )
end
Run Code Online (Sandbox Code Playgroud)

这不会促使下载,它只是在屏幕上呈现结果.我试过两个powthin服务器.

我无法弄清楚我做错了什么?

我正在使用 rails 4.0.0.beta

编辑:

CURL标题:

< HTTP/1.1 200 OK
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-UA-Compatible: chrome=1
< X-XHR-Current-Location: /contacts/export
< Content-Disposition: attachment; filename=contacts.csv
< Content-Transfer-Encoding: binary
< Content-Type: text/csv; charset=utf-8; header=present
< Cache-Control: private
< ETag: "48d3d8bd1c8d25cafb82ab705e4875ab"
< Set-Cookie: request_method=GET; path=/
< X-Request-Id: c2588883-f3f9-4f68-8a8c-0de758c47288
< X-Runtime: 0.185206
< Connection: close
< Server: thin …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails ruby-on-rails-4

11
推荐指数
2
解决办法
7608
查看次数

标签 统计

ruby-on-rails ×1

ruby-on-rails-4 ×1