From d5a5f27ae4da910bf63ba70b77cc310c60d91593 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 4 Nov 2025 16:21:01 -1000 Subject: [PATCH 1/2] Fix Turbo navigation by updating to Turbo-compatible script tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed from deprecated 'data-turbolinks-track' to modern 'data-turbo-track' attribute with 'reload' value. Also explicitly added defer: true for clarity. This fixes Turbo navigation issues in the dummy app. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- spec/dummy/app/views/layouts/application.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/dummy/app/views/layouts/application.html.erb b/spec/dummy/app/views/layouts/application.html.erb index ca89d84d47..54071c346e 100644 --- a/spec/dummy/app/views/layouts/application.html.erb +++ b/spec/dummy/app/views/layouts/application.html.erb @@ -10,7 +10,7 @@ <%= yield :head %> - <%= javascript_pack_tag('client-bundle', 'data-turbolinks-track': true) %> + <%= javascript_pack_tag('client-bundle', 'data-turbo-track': 'reload', defer: true) %> <%= csrf_meta_tags %> From 4740d4ff76ec2a2980eae65054b3e7acf93ddaf7 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 4 Nov 2025 16:48:01 -1000 Subject: [PATCH 2/2] Update Pro dummy app and docs to use modern Turbo syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address inconsistencies identified in the Turbo migration by updating: 1. Pro version dummy app layout (react_on_rails_pro/spec/dummy/app/views/layouts/application.html.erb): - Change 'data-turbolinks-track': true to 'data-turbo-track': 'reload' - Ensures consistency with main dummy app which was already updated 2. Documentation (docs/building-features/turbolinks.md): - Clarify Turbolinks 5.x vs 2.x syntax differences - Add note pointing users to modern Turbo syntax - Improve readability of legacy Turbolinks section These changes complete the Turbo migration across all dummy apps and provide clearer guidance for users on the recommended modern approach. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- docs/building-features/turbolinks.md | 11 ++++++++++- .../spec/dummy/app/views/layouts/application.html.erb | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/building-features/turbolinks.md b/docs/building-features/turbolinks.md index c7d950ddc1..6a3129b78c 100644 --- a/docs/building-features/turbolinks.md +++ b/docs/building-features/turbolinks.md @@ -128,12 +128,21 @@ This definitely can make an app perform better, even if the JavaScript and style 1. Include turbolinks via yarn as shown in the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/blob/8a6c8aa2e3b7ae5b08b0a9744fb3a63a2fe0f002/client/webpack.client.base.config.js#L22) or include the gem "turbolinks". 1. Included the proper "track" tags when you include the javascript and stylesheet: +**For Turbolinks 5.x:** + ```erb <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => 'reload' %> ``` -NOTE: for Turbolinks 2.x, use `'data-turbolinks-track' => true` +**For Turbolinks 2.x (Classic):** + +```erb + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> +``` + +**Note:** If you're using modern Turbo (recommended), use `'data-turbo-track' => 'reload'` instead of `'data-turbolinks-track'`. See the "Using Turbo" section at the top of this document. 1. Add turbolinks to your `application.js` file: ```javascript diff --git a/react_on_rails_pro/spec/dummy/app/views/layouts/application.html.erb b/react_on_rails_pro/spec/dummy/app/views/layouts/application.html.erb index 9b57229e7b..1a9adec4ef 100644 --- a/react_on_rails_pro/spec/dummy/app/views/layouts/application.html.erb +++ b/react_on_rails_pro/spec/dummy/app/views/layouts/application.html.erb @@ -22,11 +22,11 @@ <%= stylesheet_pack_tag('client-bundle', media: 'all', - 'data-turbolinks-track': true) %> + 'data-turbo-track': 'reload') %> <%# Used for testing purposes to simulate hydration failure %> <% unless params[:skip_js_packs] == 'true' %> - <%= javascript_pack_tag('client-bundle', 'data-turbolinks-track': true, defer: false) %> + <%= javascript_pack_tag('client-bundle', 'data-turbo-track': 'reload', defer: false) %> <% end %> <%= csrf_meta_tags %>