开发者

RoR, page can not be redirected if the action contain thread

I am trying to put some log from the sever to the browser. Here was what I开发者_开发百科 had done:

  • step1. start the websocket server in the action create.
  • step2. render the view which contain the websocket client to connect with the server.

step1 works but the client can not be opened in the browser, since the thread is blocked, redirect_to can not be executed.

this is code for detail.

def create
  #some code ...

  th = Thread.new{ start_server }
  format.html { redirect_to(@execution, :notice => 'Execution was successfully created.')}
  th.join
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜