
meg-gutshall
Modern Front-End Development for Rails, Second Edition - Wording (p 34)
The wording for this paragraph is a bit confusing:
A feature that makes using Turbo Streams easier from the controller side is that Rails recognizes
turbo_stream
as a format in the same way it recognizeshtml
andjson
. The Rails controller can then userespond_to
. Within yourrespond_to
block, Rails recognizesturbo_stream
as a format. As a format, that means that you can useformat.turbo_stream
to specify response behavior specific to Turbo requests. Rails will also automatically use a file withturbo_stream
as the format, the way it does for HTML and JSON, so it looks for a file named<action>.turbo_stream.erb
. When Rails recognizes that the request is a Turbo Stream, it does not use the layout when it returns the response on the theory that a Turbo response will only be interested in the body part of the page anyway. This is a small but helpful performance benefit.
I suggest something like:
A feature that makes using Turbo Streams easier from the controller side is
that Rails recognizes turbo_stream
as a format in the same way it recognizes
html
and json
. This means that you can use format.turbo_stream
to specify response behavior specific to Turbo requests within your respond_to
block. In doing so, Rails will also automatically look for a file named <action>.turbo_stream.erb
. When Rails recognizes that the request is a Turbo Stream, it does not use the layout when it returns the response on the theory that a Turbo response will only be interested in the body part of the page anyway. This is a small but helpful performance benefit.
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /centos
- /ash
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /textmate
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /slackware
- /julia
- /c
- /neovim