2

I installed the GeoCoder gem for my Ruby on Rails project and am trying to get zip codes for the cities but the postal_code is always nil. All of the cities I've put in like San Jose, CA and Seattle, WA produce a nil for the postal_code.

I'm running these example queries in my rails console:

Geocoder.search("San Jose, CA").first.postal_code

A workaround I found was to run the following but it makes 2 calls which goes against the service quota:

Geocoder.search(Geocoder.search("Seattle, WA").first.coordinates).first.postal_code

Is there a better syntax to do this?

Thanks!

perseverance
  • 6,372
  • 12
  • 49
  • 68
  • possible duplicate of [Ruby Geocoder gem to find postal code](http://stackoverflow.com/questions/8935011/ruby-geocoder-gem-to-find-postal-code) – Arslan Ali Oct 17 '14 at 12:11

1 Answers1

2

Try out this gem Area zip. It makes one call. you would do some thing like this to get the zip code

 "San Jose, CA".to_zip 
Abhay Kumar
  • 1,582
  • 1
  • 19
  • 45