Viblo CTF

ActionController::Live in Rails 4 !


Rails 4.0 will allow you to stream arbitrary data at arbitrary intervals with Live Streaming.

2.Compare rails 4 and rails 3

Rails 3 will buffer the data until the response is completed, then send everything at the same time.

Rails 4 but this time the data will be streamed to the client as every time we call the write method.

The ability to deliver whatever data you want, whenever you want.

3.There are a few caveats with this use.

You cannot write headers after the response has been committed.

You must call close on your stream when you’re finished, otherwise the socket may be left open forever.

Your actions are executed in a separate thread than the main thread. Make sure your actions are thread safe, and this shouldn’t be a problem (don’t share state across threads, etc).

  1. About Server

By default, script/rails server uses WEBrick. The Rack adapter for WEBrick buffers all output in a way we cannot bypass, so example use puma.



password download : framgia

All Rights Reserved