Question

I have an application with 3 different layouts: - 2 are for protected areas for users and admins (say user and admin layout) - the other one is the usual application layout The application layouts uses some google services (maps, fonts and analytics) whereas the other don't, so in application layout i have the scripts included and in the others not.

What happens is that when logging out from the protected areas and redirecting to home page, scripts are not called because of turbolinks.

What i've tried is:

  • to put data-no-turbolink in the link that destroys user/admin session (but no way because that is not a direct link to the home page, but just a call to an action that makes the redirect)
  • to put data-no-turbolink in the home body, but no way because i need the head to be reloaded, where the scripts are
  • to create an initPage function that contains all the things to be done at document.ready when loading the home page, but as before, scrips are not reloaded so only things that do not require exeternal services are working.

The only solution i found is to put the unneeded scripts also in the other layouts.

Any suggestion?

Was it helpful?

Solution

What about trying to add the data-no-turbolink to the logout button like this:

<%=
  link_to 'logout',
          destroy_admin_session_path,
          method: 'delete',
          class: 'btn btn-xs btn-danger',
          data: {no_turbolink: true}
%>

This should render to something like:

<a href="/admins/sign_out" class="btn btn-xs btn-danger" data-method="delete" data-no-turbolink>logout</a>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top