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
The head of the main has
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:
- There are two calls to index
- 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?
Probably something like
<meta name="turbolinks-visit-control" content="clear_cache_and_do_not_call_index_again">
<meta name="turbolinks-cache-control" content="no-cache">
on the page using the admin layout is also not helping. It still does two request.