meg-gutshall

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 recognizes html and json. The Rails controller can then use respond_to. Within your respond_to block, Rails recognizes turbo_stream as a format. As a format, that means that you can use format.turbo_stream to specify response behavior specific to Turbo requests. Rails will also automatically use a file with turbo_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.

First Post!

noelrappin

noelrappin

Author of Modern Front-End Development for Rails

Thanks for the comment, I do see where the existing version is a little wordy, I’ll clean it up.

Noel

Popular Pragmatic Bookshelf topics Top

kuroneko
Whilst the author has been careful to provide exact results for the tests elsewhere in the book (such as surds with the transformation te...
New
ianwillie
Hello Brian, I have some problems with running the code in your book. I like the style of the book very much and I have learnt a lot as...
New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
raul
Hi Travis! Thank you for the cool book! :slight_smile: I made a list of issues and thought I could post them chapter by chapter. I’m rev...
New
leonW
I ran this command after installing the sample application: $ cards add do something --owner Brian And got a file not found error: Fil...
New
nicoatridge
Hi, I have just acquired Michael Fazio’s “Kotlin and Android Development” to learn about game programming for Android. I have a game in p...
New
dsmith42
Hey there, I’m enjoying this book and have learned a few things alredayd. However, in Chapter 4 I believe we are meant to see the “&gt;...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
mert
AWDWR 7, page 152, page 153: Hello everyone, I’m a little bit lost on the hotwire part. I didn’t fully understand it. On page 152 @rub...
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New
AstonJ
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
New

Sub Categories: