-
-
Notifications
You must be signed in to change notification settings - Fork 185
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 causes nil object error #48
Comments
Hey! Thanks for response! Did you try this on new application or just on your app? What logic in your root action? |
In my app, I actually never go to the root action / "home" page, since the app is meant to run in Qt webkit, and the Qt application makes URL requests to the Rails app like "http://localhost:3000/?login=admin1@example.com&password=admin" and then the Rails app would typically respond with the proper webpage. I didn't try on a new application, just on this app. The error occurs in the webpage when I test the url and in the Qt app. (If it doesn't work in the webpage, then it definitely won't work in the Qt app - I just want to point out the error doesn't have anything to do with Qt) |
I'm sorry but I can't reproduce this bug on new rails app, and don't know your environment. If you can do some debug or tests - it will be helpful! And of course it will be super if you can do pull request with tests for this case or fix for this bug :) |
Ah, I found out the issue: I was declaring Gon.global variables in ApplicationController where there was a before_filter:
What would be the proper place to define these global gon variables? |
I advice to create some initializer for gon and create global variables there if it's possible (if there no dynamic variables). If not - you should do some singleton method which should check define of global variables and place it before call. |
Okay, since the variables are static, I should simply put them in config/initializers/mygonfile.rb ? Will it be automatically included? |
Yes, it should) If all will be ok - please close the issue) |
Actually the error has to do with setting Gon.global.myvariable anywhere, it seems... when I have it set in an initializer, the error persists. I'm digging around in your code right now, and it all starts here: gon / lib / gon / helpers.rb
The problem might stem from a misunderstanding of your include_gon method... mine has no arguments, yet Gon.clear is still being called (I suspect b/c I set global variables?) |
Could you clarify your usage section? https://github.com/gazay/gon#usage |
I found bug I think, I'll do new version tomorrow Thanks! About usage sections - I thought there are all simple - you pass some option to include gon and it's change you end javascript |
fixed in 3.0.4 |
In my Rails 3.0.9 app, I recently added gon (which is amazing), but I found that I get this error on a page, "http://localhost:3000/?login=admin1@example.com&password=admin":
I initially go to that url so as to login immediately, which this app requires (the app's actually meant to run in Qt webkit).
The full trace looks like this:
Interestingly, on other pages, gon seems to work fine...
The text was updated successfully, but these errors were encountered: