rails-widgets
rails-widgets copied to clipboard
h[key] can be nil in which case the line will bomb out...
Under Rails3.0 I'd get a "can't dup NilClass" in some random view that would render tabs.
When debuggin this I saw this here (this from the debugger):
/Users/itz/leihs-git/vendor/plugins/rails-widgets/lib/widgets/highlightable.rb:53 h_key = h[key].to_param.dup (rdb:622) l 48 end 49 elsif highlight.kind_of? Hash # evaluate the hash 50 h = clean_unwanted_keys(highlight) 51 h.each_key do |key| # for each key 52 # remove first slash from :controller key otherwise highlighted? could fail with urls such as {:controller => "/base" => 53 h_key = h[key].to_param.dup 54 h_key.gsub!(/^\//,"") if key == :controller 55 highlighted &= h_key==options[key].to_s 56 end 57 else # highlighting rule not supported (rdb:623) pp h {:controller=>"backend/models", :action=>"show", :layout=>"modal", :id=> #, :filter=>nil}
Note the last line of the printout of the "h" Hash. It's got a key with value 'nil'. Thus doing a 'h[:filter]' would give us 'nil', applying '.to_param' on 'nil' would still return 'nil'. And then calling '.dup' on nil would bomb with "can't dup NilClass".
I have no clue what's happening in the code there, I've just added a
next if h[key].nil?
but that's a band-aid only that fixes my itch but nothing more. Finding out what that 'highlighted?' method actually is expecting and what it's intended semantics are would be better.
I'm not sure why "fork and edit" wouldn't actually commit my change, whatever. Here it is:
https://github.com/tpo/rails-widgets/commit/9d366b9aad0165401af9e891660fc1a1e069bc2a