My Rails app has two layouts:
auth (sign up, sign in, password reset, ...)
admin (the app itself)
Both layouts also have their own asset packs, each marked with data-turbo-track="reload". The switch of layout happens after signing in or signing out. Because of the reload, the page is rendered twice. Once as TURBO_STREAM and a second time as HTML:
...
↳ app/controllers/auth/sign_outs_controller.rb:7:in `create'
Redirected to http://localhost:3000/sign_in
Completed 303 See Other in 46ms (ActiveRecord: 10.6ms | Allocations: 22060)
Started GET "/sign_in" for 172.21.0.1 at 2021-01-16 14:23:41 +0000
Processing by Auth::SignInsController#new as TURBO_STREAM
Rendering layout layouts/auth.html.erb
Rendering auth/sign_ins/new.html.erb within layouts/auth
Rendered auth/sign_ins/new.html.erb within layouts/auth (Duration: 1.4ms | Allocations: 664)
Rendered application/_favicon.html.erb (Duration: 4.1ms | Allocations: 3736)
Rendered layout layouts/auth.html.erb (Duration: 11.6ms | Allocations: 6827)
Completed 200 OK in 14ms (Views: 12.3ms | ActiveRecord: 0.0ms | Allocations: 8005)
Started GET "/sign_in" for 172.21.0.1 at 2021-01-16 14:23:41 +0000
Processing by Auth::SignInsController#new as HTML
Rendering layout layouts/auth.html.erb
Rendering auth/sign_ins/new.html.erb within layouts/auth
Rendered auth/sign_ins/new.html.erb within layouts/auth (Duration: 1.6ms | Allocations: 585)
Rendered application/_favicon.html.erb (Duration: 4.3ms | Allocations: 3666)
Rendered layout layouts/auth.html.erb (Duration: 11.1ms | Allocations: 5656)
Completed 200 OK in 13ms (Views: 11.6ms | ActiveRecord: 0.0ms | Allocations: 6106)
Generally, that's not too big of an issue. Except for the fact that flash messages are consumed by the first request, and will therefore not be rendered in the second request.
I have now worked around the issue by creating a single asset pack for both layouts. But I wonder if there is a way to avoid the second page render.
My Rails app has two layouts:
auth(sign up, sign in, password reset, ...)admin(the app itself)Both layouts also have their own asset packs, each marked with
data-turbo-track="reload". The switch of layout happens after signing in or signing out. Because of the reload, the page is rendered twice. Once asTURBO_STREAMand a second time asHTML:Generally, that's not too big of an issue. Except for the fact that flash messages are consumed by the first request, and will therefore not be rendered in the second request.
I have now worked around the issue by creating a single asset pack for both layouts. But I wonder if there is a way to avoid the second page render.