Turbo is precisely made to speed up page transition, but sometimes it's better to have a slower page transition - that works.

· Ruby  · 1 min read

How to disable Turbo on specific links with Rails

Turbo is precisely made to speed up page transition, but sometimes it's better to have a slower page transition - that works.

Inside the views (by default, ERB template) you can write either :

<a href="/">Home</a>

Or

<%= link_to "Home", root_path %>

Be aware that by default, Turbo is enabled, which means the home page (on the example) will not fully loaded : only elements of the body that are not the same than the current page will be replaced.

If this behaviour cause a bug, it’s ok to sacrifice speed for stability. Just write :

<a href="/" data-turbo="false">Home</a>

Or

<%= link_to "Home", root_path, data: {turbo: false} %>

Summary

Don’t stress to much about Hotwire/Turbo. Quick hack is perfect if you need to deliver fast.

Share:
Back to Blog

Related Posts

View All Posts »
The simplest turbo-frame example

The simplest turbo-frame example

Turbo frame is a powerful feature of Hotwire, here is a quick memo about how to follow conventions in the simplest case. Convention over configuration is powerful, but sometimes it is also a problem when you are not sure anymore about conventions ;) so I plan to release more "simplest *** Hotwire feature".

My honest opinion about Hatchbox

My honest opinion about Hatchbox

Hatchbox.io is a deployment platform for Ruby-on-Rails users. I used it recently, so for people ashamed of trying, here is my review.