Question

I'm building a rails application that makes use of the Turbolinks stuff that comes with Rails 4. I am also trying to use the Google+ sign in button for user authentication.

I have everything working except in one case: If the user visits more than one page before logging in, the google+ sign in process doesn't work. Basically, the Turbolinks magic is breaking the Google+ signin button. (If the user signs in right away, everything works perfectly)

That said, I can see where the problem seems to be. When the google+ js api loads, it attaches a hidden iframe to the body of the html document. This gets blown away when turbolinks loads another page. I bet this iframe is required for completing the Google+ signin process.

Has anyone crossed a similar bridge? I'm not sure how to prevent turbolinks from removing the iframe. An alternative may be to get the Google+ Api to re-initialize, but nothing like that is mentioned in the Google Plus docs.

Thanks for any insight!

Was it helpful?

Solution

I had the same issue with the Facebook login button and Bugherd sidebar.
You will need to reload your components on every page:fetch and page:change events.

Here is the pseudo code I use for facebook login:

$(document)
   .on('page:fetch', saveFacebookRoot)
   .on('page:change', restoreFacebookRoot)

I think you can do almost the same think with the Google+ iframe.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top