我有以下数据框:
??????????????????
? Code ? Airline ?
??????????????????
? 1 ? AF ?
? 1 ? KL ?
? 8 ? AR ?
? 8 ? AZ ?
? 8 ? DL ?
??????????????????
dat <- structure(list(Code = c(1L, 1L, 8L, 8L, 8L), Airline = structure(c(1L,
5L, 2L, 3L, 4L), .Label = c("AF ", "AR ", "AZ ", "DL", "KL "
), class = "factor")), .Names = c("Code", "Airline"), class = "data.frame", row.names = c(NA,
-5L))
Run Code Online (Sandbox Code Playgroud)
我的目标是让每家航空公司查找所有共享代码,即一个或多个其他航空公司使用的代码.所以输出就是
+--------------------+
| Airline …Run Code Online (Sandbox Code Playgroud) 我有一个牵线木偶布局,我想直接附加到页面的元素.
App.Views.Layouts.Unauthenticated = Backbone.Marionette.Layout.extend
template: "layouts/unauthenticated"
regions:
content: "#content"
header: "#header"
footer: "#footer"
views: {}
initialize:->
@el = $("body")
@delegateEvents()
Run Code Online (Sandbox Code Playgroud)
然后在应用程序中,我这样做
App.layouts.unauthenticated = new App.Views.Layouts.Unauthenticated()
App.layouts.unauthenticated.render()
Run Code Online (Sandbox Code Playgroud)
布局未附加到页面.我如何将身体贴在身体上,而我已经将身体用作"el",因为我不需要额外的包装.
我在与unix套接字绑定的后端(带有Puma的Rails)上有一个应用服务器,这是nginx config的相关部分
location /live/ {
proxy_pass http://app; # match the name of upstream directive which is defined above
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_set_header Connection 'Upgrade';
proxy_http_version 1.1;
chunked_transfer_encoding off;
send_timeout 300;
proxy_send_timeout 300;
keepalive_timeout 7200;
}
Run Code Online (Sandbox Code Playgroud)
SSE事件通过/ live /来,因此我调整了ngix config来处理对该路由的所有请求。
问题是连接完全在60秒后关闭。这是我在响应标题中看到的
Cache-Control:no-cache
Connection:keep-alive
Content-Type:text/event-stream
Date:Mon, 04 Nov 2013 13:41:52 GMT
Server:nginx
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-Request-Id:7065a7bc-3450-4fe2-b60c-33dfa8d41951
X-Runtime:0.010852
X-UA-Compatible:chrome=1
X-XSS-Protection:1; mode=block
Run Code Online (Sandbox Code Playgroud)
因此,似乎nginx将初始响应设置为close。为什么keepalive_timeout在这里不起作用。
在nginx error.log中我看到了
2013/11/04 13:42:52 [error] 3689#0: *9 upstream timed out (110: Connection timed out) while …Run Code Online (Sandbox Code Playgroud) 我有一个带有 Rails/Devise 服务器的 Backbone.js 客户端。
我想通过重定向实现注销过程。
这是我的客户端代码
$.ajax
url: "/sign_out"
xhrFields:
'X-CSRF-Token': $('meta[name=csrf-token]').attr('content')
type: "DELETE"
complete: xCompleteFunction = (XMLHttpRequest, textStatus) ->
#handle here?
Run Code Online (Sandbox Code Playgroud)
请求由适当的控制器方法处理。然后我有
def after_sign_out_path_for(resource)
root_path
end
Run Code Online (Sandbox Code Playgroud)
这是日志
[2012/12/11 15:44:07] (INFO) 76430 Started DELETE "/sign_out"
[2012/12/11 15:44:07] (INFO) 76430 Processing by Devise::SessionsController#destroy as */*
....
[2012/12/11 15:44:07] (INFO) 76430 Redirected to http://localhost:3000/
Run Code Online (Sandbox Code Playgroud)
Hoverer,重定向由 Rails 控制器处理,实际上重定向使用了相同的动词“DELETE”。
[2012/12/11 15:44:13] (INFO) 76430 Started DELETE "/"
[2012/12/11 15:44:13] (INFO) 76430 Processing by HomeController#index as */*
Run Code Online (Sandbox Code Playgroud)
是否可以在客户端处理重定向,并防止 Rails 控制器捕获它?我期待设计将 301/302 作为 ajax 调用的结果返回给客户端。