Data-turbolinks-track causes two calls to the Controller::index which loses the flash[:notice] from the commit

Hi,

We have two layouts. Main and Admin. A form on page using the Main layout is submitted and the user is redirected to a page on the Admin layout.

The head of the admin has

<%= stylesheet_pack_tag "admin_application_style", media: "all", 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag "admin_application", defer: true, 'data-turbolinks-track': 'reload' %>

The head of the main has

<%= stylesheet_pack_tag "main_application_style", media: "all", 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag "main_application", defer: true, 'data-turbolinks-track': 'reload' %>

The form posts to a controller as

def create
  if @organization.save
    redirect_to organizations_path, notice: 'Organization was successfully created.'
  else
    render :new
  end
end

The issue is that OrganizationsController::index is called two times. The reason for this is, as I understand it, that data-turbolinks-track sees the assets, js and css, have changed and reloads with a new call:

Turbolinks can track the URLs of asset elements in <head> from one page to the next and automatically issue a full reload if they change. This ensures that users always have the latest versions of your application’s scripts and styles.

So there are actually two issues:

  1. There are two calls to index
  2. The flash[:notice] message is rendered on the first, but is lost on the second call and no notice is shown to the user.

I understand that this is how data-turbolinks-track is supposed to work. But do you know of a way to workaround this. Probably for the form on submit to inform “turbolinks” that the assets are going to change, because it is in the admin layout and not to do a second reload because the assets have changed?

Thanks

Update 1

Probably something like

<meta name="turbolinks-visit-control" content="clear_cache_and_do_not_call_index_again">

Update 2

<meta name="turbolinks-cache-control" content="no-cache">

on the page using the admin layout is also not helping. It still does two request.