gon
gon copied to clipboard
Not loading in production; uncaught reference error
Gon works fine in development mode, but in production, it's producing an Uncaught Reference Error: gon is not defined.
I have written <%= include_gon %> in the application layout header before style sheet/ javascript tags.
Any thoughts?
Thank you for issue! Can you please provide full stack trace and example how you use gem?
It resolved itself somehow, and I'm not sure how... you can close it!
On Wed, Mar 12, 2014 at 10:42 PM, Alexey Gaziev [email protected]:
Thank you for issue! Can you please provide full stack trace and example how you use gem?
Reply to this email directly or view it on GitHubhttps://github.com/gazay/gon/issues/119#issuecomment-37501966 .
James
*Need to borrow something for occasional use? I can help http://borrows.herokuapp.com. *
I have the same problem on heroku using rails 4: 'uncaught reference error. gon is not defined'
In my gemfile I have: gem "gon", '5.0.4' and I added '<%= include_gon %>' into the head section of my layout file.
works in development though.
ok I now know what was happening, for those that stumble upon the same problem: include gon like this to make sure that it is available: <%= include_gon(:init => true) %>
and in your javascript, if you access a gon attribute, wrap it in a if to check if it is there, like this: if(gon.attr) console.log(gon.attr)
@gazay sorry to have you reopened this issue. the problem was how heroku serves all assets as one js. maybe adding a section in the usage might be of help for others.
Anyway it is and issue and add section to wiki is a good idea) Thank you, I'll do it soon.
I'm having this issue today. Gon works 90% of the time in my staging heroku app, but now that I've pushed it to my production Heroku app, it fails 90% of the time, keeping stripe.js from working. I've tried adding 'init: true' (which fails when I try to push it to Heroku), I've tried putting <%= include_gon %> in the body, as well as in the individual key pages, with no success. Has there been a solution to this other than disabling turbolinks?
+1
+1 Having this issue as well.
I never solved this issue. Ultimately, I either passed server side data into html data attributes and retrieved it with the Javascript or retrieved it with Ajax calls directly.