0

我正在尝试在我正在构建的应用程序中使用 Ruby gem Mechanize,但出现错误。

使用 Ruby 1.9.3-p0 在 IRB 中执行以下操作:

require 'Mechanize'
agent = Mechanize.new
page = agent.get('http://www.google.com')

给我以下错误:

NoMethodError: undefined method `info' for nil:NilClass
from ~/.rvm/gems/ruby-1.9.3-p0@global/gems/net-http-spy-0.2.1/lib/net-http-spy.rb:24:in 'initialize'

net-http-spy.rb 的初始化块如下所示:

def initialize(*args, &block)
  self.class.http_logger_options ||= {}
  defaults =  {:body => false, :trace => false, :verbose => false, :limit => -1}
  self.class.http_logger_options = (self.class.http_logger_options == :default) ? defaults : self.class.http_logger_options
  @logger_options = defaults.merge(self.class.http_logger_options)
  @params_limit = @logger_options[:params_limit] || @logger_options[:limit]
  @body_limit   = @logger_options[:body_limit]   || @logger_options[:limit]

  self.class.http_logger.info "CONNECT: #{args.inspect}" if !@logger_options[:verbose]

  old_initialize(*args, &block)
  @debug_output   = self.class.http_logger if @logger_options[:verbose]
end

似乎self.class.http_logger.info是导致问题的行开始,我只是不确定为什么。谁能阐明我做错了什么?

4

0 回答 0