title: Nokogiri response of empty node cache when run within application
body: <p>I have created a class within an application: </p>
  
  <pre><code>require 'nokogiri'
  require 'csv'
  require 'open-uri'
  
      class Scraper
          def self.test_method
              url = "http://london.craigslist.co.uk/"
              doc = Nokogiri::HTML(open(url))
              Rails.logger.debug doc.to_yaml
          end
      end
  </code></pre>
  
  <p>When calling this within a rails console: <code>Scraper.test_method</code> I get an empty node cache. However if I run those individual lines of the method directly in the console the response is a valid <code>Nokogiri::HTML::Document</code> object with complete node cache. </p>
  
  <p>What is different between the console and the application?</p>
  
  <pre><code>--- !ruby/object:Nokogiri::HTML::Document
  decorators:
  node_cache: []
  errors:
  - !ruby/exception:Nokogiri::XML::SyntaxError
    message: |
      Tag article invalid
    domain: 5
    code: 801
    level: 2
    file: /var/folders/lt/18lgdxts4052x8rf8xhf32v00000gn/T/open-uri20131218-62789-1tuxgqp
    line: 50
    str1: article
    str2:
    str3:
    int1: 0
    column: 28
  - !ruby/exception:Nokogiri::XML::SyntaxError
    message: |
      Tag section invalid
    domain: 5
    code: 801
    level: 2
    file: /var/folders/lt/18lgdxts4052x8rf8xhf32v00000gn/T/open-uri20131218-62789-1tuxgqp
    line: 51
    str1: section
    str2:
    str3:
    int1: 0
    column: 23
  - !ruby/exception:Nokogiri::XML::SyntaxError
    message: |
      Tag header invalid
    domain: 5
    code: 801
    level: 2
    file: /var/folders/lt/18lgdxts4052x8rf8xhf32v00000gn/T/open-uri20131218-62789-1tuxgqp
    line: 161
    str1: header
    str2:
    str3:
    int1: 0
    column: 36
  - !ruby/exception:Nokogiri::XML::SyntaxError
    message: |
      Tag footer invalid
    domain: 5
    code: 801
    level: 2
    file: /var/folders/lt/18lgdxts4052x8rf8xhf32v00000gn/T/open-uri20131218-62789-1tuxgqp
    line: 678
    str1: footer
    str2:
    str3:
    int1: 0
    column: 9
  </code></pre>