Turbo Frames 304 code - small problem with displaying new form on index page using traditional Rails scaffold

In order to understand turbo frames, I generated scaffold cars brand model

And as an exercise I wanted to display “new form” on the index page, instead of doing full html body replacement

So I wrapped link_to "new car" on an index page into turbo_frame_tag "new_car"

And then I also wrapped everything inside new.html.erb file in a corresponding turbo_frame_tag "new_car"

Plus as a finishing step I also changed the redirect_to path in create action inside cars_controller.rb

To redirect to cars_url instead of car_url(@car) in order to properly hide this form after successfully creating a record

And it works! Everything looks fine at least at the first glance when I click through the basic flow and when the url in the browser tab stays the same localhost:3000/cars

However I was curious what would happen when I’ll enter localhost:3000/cars/new into the address bar manually, how would the turbo frame behave?

And here is the problem, the turbo frames previously defined seemed like stuck in an infinite loop, I cannot return back to full index page


So how to solve that?

Because I cannot simply remove /cars/new route to prevent the potential user from accessing it because it is necessary for a scaffold to work

I cannot also add data: { turbo_frame: :_top } to escape the frame because it also breaks the initial proper implementation

So what to do, what am I missing? What does the 304 code mean in this case?

And how this github issue relates to my problem

Was it already solved?

the correct flow below