我遇到了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)
这不会促使下载,它只是在屏幕上呈现结果.我试过两个pow和thin服务器.
我无法弄清楚我做错了什么?
我正在使用 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) 如果我有一个1核心的服务器,有多少puma worker,thread和什么数据库池大小合适?
一般大拇指在这里是什么?
我遇到了Twitter bootstrap和Rails数据远程链接的问题.
我加载模态内容data-remote="/path/to/data".一切都按我的要求工作但是要创建两个请求.
= link_to '#myModal', 'Click here', data: {toggle: 'modal', remote: '/path'}
Run Code Online (Sandbox Code Playgroud)
第一个是rails data-reomte,它向我所在的页面发出请求,然后在该引导程序发出他的请求并显示模态.
有没有什么方法可以在指定的链接上转动rails远程或者它实际上是另一个问题?
假设我有两个型号.Project和Task.任务必须属于项目.
以下哪个URL端点是最佳做法?
https://api.myapp.com/projects/:project_id/tasks/:task_idhttps://api.myapp.com/tasks/:task_id?project_id=:project_id对于过滤结果我总是使用查询参数但我想知道我们应该用所需的参数做什么?