Turbo Streams: HTTP
This course covers Turbo Streams sent as HTTP responses. A format.turbo_stream branch in an ordinary respond_to block answers the request that triggered it, chosen by the client's Accept header. The lessons read real controllers and templates from one Rails app. A comment form returns five actions in one response. A loop appends a page of comments and replaces the load more control. Other lessons cover inline render turbo_stream calls with status codes, one-line remove and refresh templates, and format.html fallback branches.
What you'll learn
- ✓How the Accept header picks a format.turbo_stream or format.html branch
- ✓Sending several targeted stream actions in one HTTP response
- ✓Looping in a .turbo_stream.erb template to append a page of comments
- ✓Rendering one action inline with render turbo_stream: and an HTTP status
- ✓Using remove with dom_id and refresh with method: :morph over HTTP
- ✓Pairing each stream branch with a complete format.html fallback
The same respond_to, a second format
Every broadcast in the last course fired without any request: a push from the server, with nobody asking. This course's turbo stream answers a question instead. An ordinary form submission, over ordinary HTTP, gets its answer from format.turbo_stream, one branch of the same respond_to block Rails…
Read the full lesson free →Curriculum
7 lessonsThe same respond_to, a second format
How format.turbo_stream in a respond_to block answers a request, with the Accept header choosing the branch.
Multiple actions, one response
One comment POST returns five targeted stream actions, all run in template order within one animation frame.
Looping into a stream response
A .turbo_stream.erb loop appends a page of comments, then replaces the load more control with the next page.
render turbo_stream: inline, and real status codes
Rendering one action inline with render turbo_stream:, sending a 422 status, or answering with a bare head :forbidden.
remove, dom_id, and refresh over HTTP
Two one-line templates: remove with dom_id for a deleted image, and refresh with morph for a locale switch.
Progressive enhancement: two formats, one action
Each controller pairs format.turbo_stream with a complete format.html branch, though the interface still needs JavaScript.
Putting it together: two courses, one mechanism
A review showing that broadcasts and HTTP responses carry the same turbo-stream actions, and why there is no coding challenge.