B
B
beginner2016-07-06 19:34:31
Ruby on Rails
beginner, 2016-07-06 19:34:31

How to make a redirect after the completion of the execution of the thread (Thread.new)?

Used Thread.new, how to make a redirect after running a task in the background?
Thread.new do
task
sleep 1
redirect_to :root
end
writes "Redirected to" in the console and that's it, nothing happens! how to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2016-07-07
@AMar4enko

Thread.new do
...
end.join
redirect_to :root
It just doesn't make sense, the web application thread will still be busy during the execution of the task inside Thread.new

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question