Forum: Ruby-Forum.com NoMethodError and You have a nil object error message

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9dbf4f3919f75179e3da7af40dfc8c6a?d=identicon&s=25 Mt Tahiliani (mtahiliani)
on 2008-09-18 02:42
Hi,

New to ruby/rails. For my controller class as defined below, I get the
exception printed below the class definition. Have absolutely no idea
how to resolve it. Look forward to your help!

*************************************

class HelloController < ApplicationController
def sayhello
require 'rubygems'
require 'scrubyt'

dell_data = Scrubyt::Extractor.define do
  fetch
'http://support.dell.com/support/topics/global.aspx...
  fill_textfield 'ServiceTag', '3CTVR41'
  submit

dell_data do
     serviceTag "/tr[1]/td[2]"
     systemType "/tr[2]/td[2]"
     shipDate "/tr[3]/td[2]"
     dellIBU "/tr[4]/td[2]"
end
end

render :text => dell_data.to_xml

end
end

**********************************************

NoMethodError in HelloController#sayhello
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.parent
RAILS_ROOT: C:/Monica/flexiblerails/current/dbaccess

Application Trace | Framework Trace | Full Trace
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/utils/xpathutils.rb:13:in
`lowest_common_ancestor'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/scraping/filter.rb:123:in
`generate_XPath_for_example'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/scraping/filter.rb:122:in
`each'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/scraping/filter.rb:122:in
`generate_XPath_for_example'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/scraping/filter.rb:113:in
`loop'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/scraping/filter.rb:113:in
`generate_XPath_for_example'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/evaluation_context.rb:116:in
`generate_examples'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/evaluation_context.rb:116:in
`each'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/evaluation_context.rb:116:in
`generate_examples'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/evaluation_context.rb:115:in
`generate_examples'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/evaluation_context.rb:115:in
`each'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/evaluation_context.rb:115:in
`generate_examples'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/evaluation_context.rb:58:in
`setup_examples'
c:/ruby/lib/ruby/gems/1.8/gems/scrubyt-0.2.6/lib/scrubyt/core/shared/extractor.rb:38:in
`define'
app/controllers/hello_controller.rb:6:in `sayhello'
This topic is locked and can not be replied to.