}>
doc/‘p’
NoMethodError: You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
from /Library/Ruby/Gems/1.8/gems/hpricot-0.6/lib/hpricot/traverse.rb:
279:in `/’
from (irb):7
I am using the system installed hpricot v0.6 gem (not in vendor/gems).
Now I am pretty sure this is not really Hpricot’s fault. The same code
works in a fresh rails application. Probably something in my code is
causing this error. But I am not able to see where. None of my other
plugins are using Hpricot. I am calling Hpricot only from one method
in application_helper.rb. This error cropped up when my frozen Rails
version was 2.0.1. I froze rails again to the edge version (r9208).
But nothing helped.
Any pointers on where should I look to fix this? Any settings to tweak
in my rails app? I am lost on this right now.
lorem ipsum <a href=“http://dolor.com/”>dolor sit amet.</
from (irb):7
If you want to make things real interesting, the same thing from my
rails app was fine. Can’t think of anything better to suggest than to
step through it with the debugger and try and understand the problem a
little more.
If you want to make things real interesting, the same thing from my
rails app was fine. Can’t think of anything better to suggest than to
step through it with the debugger and try and understand the problem a
little more.
Ok, how do I debug the Rails stack? I normally use debugger with the
‘ruby-debug’ gem. I can debug through my code but how do I debug the
stack and see how it loads Hpricot?
It turned out to be a rogue plugin which was
carelessly overriding the String Class ‘match’ method to its own
hacked version. This caused the Hpricot error.
In exactly the same way. I would put a breakpoint where the error
happens and try and work out what’s going on.
I enabled the backtrace option, browsed through the application and
zeroed onto the problem. It turned out to be a rogue plugin which was
carelessly overriding the String Class ‘match’ method to its own
hacked version. This caused the Hpricot error. That teaches me for
indiscriminately using plugins!
Thanks Fred.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.