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
include_gon helper is not supports on Rails 4 #90
Comments
use this helper to use in Rails <%= include_gon(:init => true) %> It solves my problem in Rails 4 |
Thank you for issue! Unfortunately I haven't touch rails 4 because of scope of my current work. I'll try to dig into by myself when I get some time but it will be super if can help me to realize where is the problem or maybe make some falling test) Thanks again! |
Any progress on this? |
Not yet =( |
@saturday can you give this a try:
|
Both of these create the gon object: <%= include_gon(:init => true) %>
<%= Gon::Base.render_data({}) %> However they end up being empty js objects. If I don't use either of the above the gon object isn't created at all as @krishnasrihari mentioned. |
worked for me :) |
I can't reproduce this on new rails 4 application. Helper is working for me. Can someone provide simple app which reproduce this issue please? |
The helper was working for me in my 4.0.0 project but now it isn't... trying to figure out what changed |
OK... embarrassingly (being new to Ruby on Rails), I have declared my index action after the protected keyword but because my view was still loading, I didn't notice. The gon view helper is working just fine for me in Rails 4 |
So I still can't reproduce not working helper in rails 4. It was stopper for release new version, and I think without sample application with not working gon helper I'll release new version in few days without some fixes for this issue. |
I think I'm experiencing this very same issue, sometimes I get a You can see my app here Hope it helps! |
Thanks a lot, I'll dig into it |
Hey, so I kept working on that app and realize the |
what @touchdown said work for me! I had to pull directly from the repo, though EDIT: after finally getting the helper to work, gon is just doing random things, sometimes saves, sometimes not. Has someone experienced that? |
@sebastialonso try new 5.0.4 version, it should work without workarounds. |
@gazay I will, thanks. |
@gazay Hey, just wanted to echo that I'm having similar issues with gon, namely that it was undefined. Found that calling "window.gon.variable_name" in my javascript was a successful workaround. Side note, really great gem, extremely useful, thanks for your help/work! |
@vorDd can you tell what exactly was the problem? I'll try to research it |
Not sure what the current status of gon is. Using rails 4.1.1 and ruby 2.1 and gon 5.1.2, I'm getting
|
init worked for me |
Rails 4.1.7, Ruby 2.1.2 and Gon 5.2.3. Same issue getting ReferenceError: Can't find variable: gon. Any help appreciated. |
I never sorted out my problem with gon, realized that websockets was closer to what I needed. |
|
Ok, here's how we fixed it. The problem was that Gon wasn't spitting out properly encoded script tags, so I set :need_tag => false and pasted the following code into the head:
Works as expected now. |
What would be the full the code for that?
|
My gon code is working on local host but not on a digital ocean VPS, any suggestions? |
The reason for this change is that in rails4 the "<%= include_gon %>" throws 'gon not found' error. I was facing this issue with my rails 4.1 app. And it wasted my time a lot. I would suggest that for now, if we can add the solution given in gazay#90 in the readme file will help to others a lot.
I just created a rails 4.2.0 app and gon isnt working :( = Gon::Base.render_data({}) |
I have the same problem as @christianonrails |
Hello all! Please provide smallest app which reproduces this error – when I'm creating new rails 4.0-4.2 apps I don't have any problem with |
I see the same issue whenever I go to the page from a page without gon, specifically from the Rails_admin page (different engine.) Using windows.gon.variable solved it. So the turbolinks gem for waiting on page load must not work in that case. |
Neither |
Gon is not working on the latest version of rails with or without turbolinks. Please fix. |
Using Rails 4.2 and Puma. Tried include_gon and include_gon(:init=> true_ and Base.render_data. The only time gon worked was the first time after installing the gem |
@TheDerek can you provide example app that reproduces this error please? In my new projects on rails 4.0-4.2 I can't reproduce it. |
It seemed to have fixed itself when I restarted the rails server. I've On Sun, Mar 29, 2015 at 9:55 PM, Alexey Gaziev notifications@github.com
|
I am working on a Rails 4 application and I used to have the same error, but adding |
I used |
Just to confirm. Prior to installing this gem I searched the issues to make sure it would work with turbolinks and rails >=4. I can confirm it works if you use
Maybe best to include this in the readme because now it says:
and that doesn't work. BTW: Thanks for the gem! |
As for
OR:
There was no need for specifying both because they are doing same thing. BTW: README update would be nice :) |
I also encountered this problem. I have used all the possible lines in the def update
respond_to do |format|
if @research_record.update(research_record_params)
if @research_record.tag_draft
gon.content = ApplicationHelper.markdown @research_record.content
format.js { render action: :preview }
... In alert(gon.content); |
I am having the same issue with Rails 4.2.3 ruby 2.1.2. I also confirmed this worked and it would be nice if it were on the GitHub landing page info. Still in the javascript the compiler does not like the gon. prefix as a variable name. Basically it does not work any help would be nice. I am going to try to dig deeper but someone with code experience could find it much faster. Help Thanks for the gem if it worked it would be of great use. |
Rails 4.2.0, include_gon works just fine here without "Gon::Base.render_data" |
Using Rails 4.2.4 w/ Turbolinks, was getting undefined after creating a new object and going back to the index page. My fix was to move |
Thank You I will give this a try. On Sat, Oct 24, 2015 at 2:50 PM, Philip Yoo notifications@github.com
|
FYI - On Sat, Oct 24, 2015 at 4:24 PM, Wayne Mattingly whoru7777777@gmail.com
|
I've started using |
FWIW I can reproduce this problem if you use |
Gon fails on |
I am having the same issue, it's returning empty {} when called from application.js but when print it in the controller, the variable gets assigned. I have this tag in application.html.haml '= include_gon :watch => true, :init => true', and simple assignment in controller gon.your_int = 5. I was working on my school project and was trying to see if someone can help me with this issue. |
No description provided.
The text was updated successfully, but these errors were encountered: