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
精彩评论