NoMethodError "Read" for URI

Hey Everyone,

I have a pretty interesting problem that I thought I would try and get some feedback on. The following method below accepts a URL string as a parameter ex "http://www.google.com," and it uses regular expressions to try and find the images in the html. The odd thing is.... that I have tested it over and over again.... and it has always grabbed the images and worked exactly as I coded it too, but lately it has been telling me that the URI class doesn't have a read method.... when it must because I have been using it!

I am just so confused why rails would suddenly have this issue, and I am wondering if anyone can make heads or tails out of it. The code is posted below.

Thanks!

<================== CODE ===========================================>

def get_images(url)     @image_links =

    if validate_link(url) == false       return @image_links     end

    if ((url =~ /\.jpg/)||(url =~ /\.png/)||(url =~ /\.gif/)) == nil         begin           uri = URI.parse(url)           str = uri.read           host = uri.host         rescue SystemCallError           return @image_links

        end

        @body = str.scan(/<body.+<\/body>/)         @images = str.scan(/(src=\"http.+\.jpg?\")/)         str = @images.to_s         @images = str.scan(/\".+?\"/)         @image_links = filter_images(@images)         @image_links.push("no_image.jpg")     else           @image_links.push(url)           @image_links.push("no_image.jpg")     end

    return @image_links   end

oh and I thought I should provide the error message itself:

NoMethodError (undefined method `read' for #<URI::HTTP:0x256f764>):

oh and I thought I should provide the error message itself:

NoMethodError (undefined method `read' for #<URI::HTTP:0x256f764>):

URI does not have an read method. OpenURI adds one, so the logical
conclusion for me is that something in your environment has changed
that results in openuri not having been required when previously it was.

Fred

Thanks Fred,

I checked it out, and you were right. Open-URI is required now, and it works like a charm.

Casen