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 »
Rails 8 Bootstrap 5 tutorial

Rails 8 Bootstrap 5 tutorial

A very simple tutorial about Rails 8 and Bootstrap 5, since starting with Boostrap is already given by the framework by default with little config.

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.