Cesare Ferrari

July 20, 2022

How to disable Turbo Drive in a Rails application


Turbo Drive intercepts link clicks and form submissions and generates Ajax calls to speed up page refresh. It comes enabled by default in a Rails 7 application.


Sometimes, though, we may be in a situation where we need to disable Turbo Drive in order to force a full page refresh when we click a link or submit a form.


To disable Turbo Drive on a link we just add the data-turbo="false" attribute in this way:

<%= link_to "New thing", new_thing_path, data: { turbo: false } %>

To disable Turbo Drive on a form submission we do the same. Here’s a sample snippet:

<%= form_with model: @member,
                    url: admin_members_path,
                    class: "mb-12"
                    data: { turbo: false } do |f| %>

...

<% end %>