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.