Skip to content

Loading…

Fix issue with jQuery 1.8.1. #78

Merged
merged 1 commit into from

2 participants

@jarib

I recently upgraded from jQuery 1.7.2 to 1.8.1 in a Rails app, and noticed this error in my logs:

[2012-09-26 01:05:19] ERROR NoMethodError: undefined method `each' for "":String
    /Users/fijabakk/src/git/MiniProfiler/Ruby/lib/mini_profiler/client_timer_struct.rb:40:in `init_from_form_data'
    /Users/fijabakk/src/git/MiniProfiler/Ruby/lib/mini_profiler/profiler.rb:111:in `serve_results'
    /Users/fijabakk/src/git/MiniProfiler/Ruby/lib/mini_profiler/profiler.rb:139:in `serve_html'
    /Users/fijabakk/src/git/MiniProfiler/Ruby/lib/mini_profiler/profiler.rb:195:in `call'

The app is using the use_existing_jquery setting. It looks like jQuery may be serializing null differently than before (though I haven't tried to track down the exact version that introduced the change).

This PR fixes the issue by checking for an empty string in addition to "null". I added the empty value to spec/fixtures/weird_client_request.yml so it's caught by the specs.

Thanks for an awesome tool!

@SamSaffron SamSaffron merged commit 829a84d into SamSaffron:master
@SamSaffron
Owner

thanks, keep the patches coming

@SamSaffron
Owner

we should probably clean the js up a bit though, the interface is a bit wonky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2012
  1. @jarib
Showing with 3 additions and 2 deletions.
  1. +1 −1 Ruby/lib/mini_profiler/client_timer_struct.rb
  2. +2 −1 Ruby/spec/fixtures/weird_client_request.yml
View
2 Ruby/lib/mini_profiler/client_timer_struct.rb
@@ -36,7 +36,7 @@ def self.init_from_form_data(env, page_struct)
probes = form['clientProbes']
translated = {}
- if probes && probes != "null"
+ if probes && !["null", ""].include?(probes)
probes.each do |id, val|
name = val["n"]
translated[name] ||= {}
View
3 Ruby/spec/fixtures/weird_client_request.yml
@@ -1,5 +1,6 @@
---
rack.request.form_hash:
+ clientProbes: ''
clientPerformance:
navigation:
redirectCount: 99
@@ -10,4 +11,4 @@ rack.request.form_hash:
weirdEnd: 1334245955
previousStart: 1334245950
previousEnd: 1334245952
- differentFormat: 1334245955
+ differentFormat: 1334245955
Something went wrong with that request. Please try again.