Skip to content

Conversation

@tpo
Copy link

@tpo tpo commented Jun 28, 2011

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.

@tpo
Copy link
Author

tpo commented Jun 28, 2011

I'm not sure why "fork and edit" wouldn't actually commit my change, whatever. Here it is:

tpo@9d366b9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant