# Hpricot for help!

**URL:** <https://www.ruby-forum.com/t/hpricot-for-help/76890>\
**Category:** Rails\
**Created:** [November 22, 2006, 5:35am UTC](https://www.ruby-forum.com/t/hpricot-for-help/76890 "2006-11-22T05:35:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacquie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jacquie](https://www.ruby-forum.com/u/jacquie)\
**Post date:** [November 22, 2006, 5:35am UTC](https://www.ruby-forum.com/t/hpricot-for-help/76890/1 "2006-11-22T05:35:28Z")

</div>

Hi,there

I’ve recently used hpricot to parse xml result. The code is as shown in  
[http://apassant.net/blog/post/2006/08/29/108-geolocation-with-ruby-on-rails-and-google-maps](http://apassant.net/blog/post/2006/08/29/108-geolocation-with-ruby-on-rails-and-google-maps)

while I seem to be able to get it to work in irb, it didn’t work in my  
application.

The difference seems to be in  
require ‘open-uri’  
require ‘rubygems’  
require ‘hpricot’

while in irb, they all return true. in the function that’s being  
called,I setup a breakpoint and can see that these three values are  
false.

anybody has ideas what happened?

Greatly appreciated for any help!

---

<div class="post-metadata">

**Author:** ![jacquie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jacquie](https://www.ruby-forum.com/u/jacquie)\
**Post date:** [November 22, 2006, 6:13am UTC](https://www.ruby-forum.com/t/hpricot-for-help/76890/2 "2006-11-22T06:13:55Z")

</div>

Is your rails app definitely hitting the same ruby binary that  
running irb or your command-line ruby script? Almost sounds like  
either you’re hitting a second (or older) install that doesn’t have  
some of the libs you’re trying to require, or else ruby’s load paths  
are getting jacked up somewhere along the way if the requires are in  
fact failing in your rails app.

Also, you may want to check out the google\_geocode library:

[http://dev.robotcoop.com/Libraries/google-geocode/](http://dev.robotcoop.com/Libraries/google-geocode/)

I’ve used it in essentially the same exact way you’ve described in  
your blog post, as a before\_save in my model, works wonderfully.  
Looks like your method would work just as well, just thought I’d  
point out an alternate solution.

---

<div class="post-metadata">

**Author:** ![jacquie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jacquie](https://www.ruby-forum.com/u/jacquie)\
**Post date:** [November 22, 2006, 6:33am UTC](https://www.ruby-forum.com/t/hpricot-for-help/76890/3 "2006-11-22T06:33:08Z")

</div>

Thanks for your reply JD. You might be right since I’ve installed  
a few ruby versions and need to clean up.

I setup the ruby path to C:/ruby/bin; so I thought both of the  
applications  
and irb should go for this path? how do I check if they use the same  
ruby binary?

Thanks!

JD Harrington wrote:

> Is your rails app definitely hitting the same ruby binary that  
> running irb or your command-line ruby script? Almost sounds like  
> either you’re hitting a second (or older) install that doesn’t have  
> some of the libs you’re trying to require, or else ruby’s load paths  
> are getting jacked up somewhere along the way if the requires are in  
> fact failing in your rails app.
> 
> Also, you may want to check out the google\_geocode library:
> 
> [http://dev.robotcoop.com/Libraries/google-geocode/](http://dev.robotcoop.com/Libraries/google-geocode/)
> 
> I’ve used it in essentially the same exact way you’ve described in  
> your blog post, as a before\_save in my model, works wonderfully.  
> Looks like your method would work just as well, just thought I’d  
> point out an alternate solution.

---

<div class="post-metadata">

**Author:** ![jacquie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jacquie](https://www.ruby-forum.com/u/jacquie)\
**Post date:** [November 22, 2006, 11:32am UTC](https://www.ruby-forum.com/t/hpricot-for-help/76890/4 "2006-11-22T11:32:19Z")

</div>

On 11/21/06, jacquie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> require ‘open-uri’  
> require ‘rubygems’  
> require ‘hpricot’
> 
> while in irb, they all return true. in the function that’s being  
> called,I setup a breakpoint and can see that these three values are  
> false.
> 
> anybody has ideas what happened?
> 
> Greatly appreciated for any help!

If require returns false it only means the library is already loaded -  
it doesn’t mean there is an error. If there is an error require  
raises an exception.

So in your app you already have those libraries loaded when you  
require - so its nothing to worry about .

- rob  
–  
[http://www.robsanheim.com](http://www.robsanheim.com)  
[http://www.seekingalpha.com](http://www.seekingalpha.com)  
[http://www.ajaxian.com](http://www.ajaxian.com)
