-
Notifications
You must be signed in to change notification settings - Fork 242
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
Undefined Method 'headers' without request object but with Turbolinks included #194
Comments
MauricioMoraes
changed the title
Undefined Method 'headers' without requests but with Turbolinks included
Undefined Method 'headers' without request object but with Turbolinks included
Jun 8, 2015
MauricioMoraes
added a commit
to MauricioMoraes/lazy_high_charts
that referenced
this issue
Jun 9, 2015
This commit solves issue michelson#194. The request object is verified on the if clause but not on the elsif part, breaking when calling the headers method on the object that doesn't exist. This is an inprovement on the code robustness that doesn't seem to break anyone's code.
MauricioMoraes
added a commit
to MauricioMoraes/lazy_high_charts
that referenced
this issue
Jun 9, 2015
Still on issue michelson#194. The request method could be defined and still be returning nil. With respond_to? on line 37, it already covered the case where request was undefined. It's crearer without the "defined?" method.
Hi there, ran into a similar issue today except for me defined?(Turbolinks) && defined?(request) && request.respond_to?(:headers) && request.headers["X-XHR-Referer"] I'd be happy to submit a PR if you're interested. |
Hi @KCErb! That's great it's not just happening to me! I'm already using this branch in production, and that's why I forked it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We've been using LazyHighCharts in our system for a long time now, and now we're refactoring it to use Turbolinks.
Now I'm getting this error:
It happens when I call the method
high_chart
on my view.The problem is that, due to the way I've structured my code, I don't have the
request
object, so it crashes right here:lazy_high_charts/lib/lazy_high_charts/layout_helper.rb lines 37 to 69, most specifically in line 45
I could refactor all my code and call the controller without the
send_data
method, as I'm doing, just to have therequest
object, but it makes sense to me to verify if therequest
object exists on line 45, as its done on line 37 of the file above. This will make the code more robust, and doesn't seem to break anyone's code.Then, line 45 would become:
Does it make sense to you? Should I make a pull request?
Thanks
The text was updated successfully, but these errors were encountered: