Rails webscraper works in console, but not server
===

I've been hammering out some methods and testing them in the console.  The problem is that running them on the server, it causes as error.  Specifically, the first method below triggers this NoMethod error:
    undefined method `text' for nil:NilClass

Here's the code.  It's from the website.rb file, which has a uri column.  

    def download_page_title
      page_as_xml.at_css('title').text
    end
   
    def page_as_xml
      page_as_xml ||= Nokogiri::HTML(open(page_uri))
    end

    def page_uri
      base_uri = Site.find_by_id(self.site_id).homepage #always has "/" at end
      if self.url == base_uri
        page_uri = base_uri
      else
        page_uri = "#{base_uri}#{self.url}"
      end
    end

Any idea what I'm doing wrong?  Also, any idea why things go smoothly in console but derail on the server?