Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem gon navigate with turbolinks #254

Open
igortice opened this issue Dec 18, 2018 · 2 comments
Open

Problem gon navigate with turbolinks #254

igortice opened this issue Dec 18, 2018 · 2 comments

Comments

@igortice
Copy link

peek 18-12-2018 10-46

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
Copy link

baran commented Dec 24, 2018

Hi,

I'm having the same problem. In addition, the existing problem seems to have never been assigned. It seems that the values have been passed to the variables in the first run.

rails version: 5.2.2
ruby version: 2.5.3
gon version: 6.2.1

screen shot 2018-12-24 at 13 00 06

@windy
Copy link

windy commented Aug 12, 2019

Hi, I found this problem, and resolved by this way:

Change <%= Gon::Base.render_data %> from head to body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants