Problem gon navigate with turbolinks
igortice opened this issue · 2 comments
igortice commented
rails version: 5.2.2
ruby version: 2.5.3
gon version: 6.2.1
I have two actions:
class IndexController < ApplicationController
def index
@your_int = 123
@your_array = [1,2]
@your_hash = {'a' => 1, 'b' => 2}
gon.your_int = @your_int
gon.your_other_int = 345 + gon.your_int
gon.your_array = @your_array
gon.your_array << gon.your_int
gon.your_hash = @your_hash
end
def about
end
end
in my header i put gon:
%meta{content: 'text/html; charset=UTF-8', 'http-equiv': 'Content-Type'}
%meta{content: 'no-cache', name: 'turbolinks-cache-control'}
= Gon::Base.render_data
%title Testes
-#= favicon_link_tag
= csrf_meta_tags
= csp_meta_tag
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
in browser colose on page index i write gon and returns this:
gon
{your_int: 123, your_other_int: 468, your_array: Array(3), your_hash: {…}}
i navigate with turbolinks to page about and i write gon from console and return this:
gon
{}
so i back to index with tuborlinks and i write in console gon and the return not put the value, but an empty object
gon
{}
baran commented
windy commented
Hi, I found this problem, and resolved by this way:
Change <%= Gon::Base.render_data %>
from head to body.