How can I "flush" output in Ruby on Rails 3?
In PHP I would do something l开发者_C百科ike the following:
$i = 0;
$total = count($result);
foreach ( $result as $item ) {
$i++;
time_consuming_action($item);
echo "Finished $i of $total<br>";
flush();
}
I do believe there is a plugin for that.
https://github.com/oggy/template_streaming
STDOUT.flush
works for regular Ruby.
template_streaming does not support Rails 3, yet...
https://github.com/oggy/template_streaming/issues/closed#issue/4
精彩评论