Mid-level Track Roadmap

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
Free preview · Lesson 1 3 min read

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 lessons
Type to start searching...