I believe everything is working as expected here. You’re seeing Turbolinks’ preview cache in action:
[D]uring standard navigation (via Application Visits), Turbolinks will immediately restore the page from cache and display it as a preview while simultaneously loading a fresh copy from the network. This gives the illusion of instantaneous page loads for frequently accessed locations.
The first controller is initialized when Turbolinks renders the preview. Then the preview <body> is replaced by fresh page content loaded over HTTP, which initializes a second controller.
Try these two things to confirm:
- Log in
connect()anddisconnect()instead ofinitialize(). You should see a corresponding call todisconnect()for the first controller before the second controller connects. - Log the value of
document.documentElement.hasAttribute("data-turbolinks-preview"). You should seetruewhen Turbolinks is showing the preview.