You can change the code one of two ways to get it to work

This way which is useful if you want, for example,  to use a particular
version of the library

require 'rubygems'
require 'net/http'
require 'uri'
require_gem 'hpricot', '=0.4'
require 'hpricot'

or this way to use the latest version

require 'net/http'
require 'uri'
require 'hpricot'

Luis


Allison Newman wrote:
> I've run into a wierd problem with the Hpricot gem.  I don't know if
> this is a problem with gems in general on my system, or if it's specific
> to Hpricot, so I'm posting here.
>
> Basically I have code as follows:
> require 'rubygems'
> require 'net/http'
> require 'uri'
> require_gem 'hpricot'
>
> class Page
>   def some_function(html_text)
>     doc = Hpricot(html_text)
>     doc.search("/html/body//img").each do |img|
>        logger.debug("== Found an image: #{img} ==")
>        src = img[/src="/]
>        logger.debug("src = #{src}")
>      end
>   end
> end
>
>
> When the function is called, sometimes I get a message saying that
> function Hpricot does not exist for the object of type Page.  this
> continues for the entire programming session.
>
> But sometimes, when I sit down to work on the project, the code works!
> It continues working until I restart the Rails server (this is a Rails
> project running on MacOSX).
>
> Does anyone have any idea what might be causing this problem, and how to
> correct it?
> 
> Alli
> 
> -- 
> Posted via http://www.ruby-forum.com/.