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
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /js
- /swift
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /c-plus-plus
- /flutter
- /preact
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /nim
- /vuejs
- /emacs
- /nerves
- /elm