# Need a zip/postal code database or plugin for rails

**URL:** <https://www.ruby-forum.com/t/need-a-zip-postal-code-database-or-plugin-for-rails/127885>\
**Category:** Rails\
**Created:** [February 2, 2008, 5:27am UTC](https://www.ruby-forum.com/t/need-a-zip-postal-code-database-or-plugin-for-rails/127885 "2008-02-02T05:27:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2008, 5:27am UTC](https://www.ruby-forum.com/t/need-a-zip-postal-code-database-or-plugin-for-rails/127885/1 "2008-02-02T05:27:02Z")

</div>

Anyone here has an idea of any good database or RoR plugin for zip and  
postal codes ???

Thank you…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2008, 5:51am UTC](https://www.ruby-forum.com/t/need-a-zip-postal-code-database-or-plugin-for-rails/127885/2 "2008-02-02T05:51:37Z")

</div>

I’m not sure of a plugin for it, but for US addresses you could try  
the web services provided by the USPS:

[http://www.usps.com/webtools/technical.htm](http://www.usps.com/webtools/technical.htm)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2008, 6:22am UTC](https://www.ruby-forum.com/t/need-a-zip-postal-code-database-or-plugin-for-rails/127885/3 "2008-02-02T06:22:31Z")

</div>

What do you need to do with it? I asked this exact same question a while  
ago because I needed a way to search for an item based on its distance  
from a certain zipcode. I ended up stumbling onto GeoKit which is an  
amazing rails plugin for geocoding locations and performing a variety of  
related tasks.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2008, 6:27pm UTC](https://www.ruby-forum.com/t/need-a-zip-postal-code-database-or-plugin-for-rails/127885/4 "2008-02-02T18:27:22Z")

</div>

I have a CSV file for all zip codes in the US:  
Code,Latitude,Longitude,City,State,County,Type

Load all the zips in a table and use GeoKit so that I can find  
distance qualifications by address (zip\_code) without the expense of  
hitting a geocoder. Much faster and 100% available. It’s also useful  
for classifying people by county (which geocoders can not do), and for  
presenting a list of cities, or auto-completing the city/state when  
someone enters a zip.

Just keep in mind that the lon/lat is for the CENTER of the zip\_code  
area and may or may not fit your accuracy needs.

It may not be 100% correct, but it does have my home zip\_code which  
became active only last year, so it looks pretty good to me.

Just drop me an email if you would like a copy. Also let me know if  
you would like a model and import script for importing the file.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 3, 2008, 3:01am UTC](https://www.ruby-forum.com/t/need-a-zip-postal-code-database-or-plugin-for-rails/127885/5 "2008-02-03T03:01:23Z")

</div>

On Feb 2, 1:55 pm, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> To be honest, what I was more in need for is a db or a plugin for  
> country/state drop down…  
> But since I don’t know how my app is going to evolve, I tought it’d be  
> better to get  
> the full thing now (zip codes etc…). I’ve heard about GeoKit and  
> I’ve seen the API,  
> its nice but isn’t that a bit too much, since I don’t plan to be  
> making a map app???  
> What could you suggest me ??? thx for your time.

Well, you can use the us\_states plugin to create a  
us\_state\_options\_for\_select (selection list).  
[http://svn.techno-weenie.net/projects/plugins/us\_states/](http://svn.techno-weenie.net/projects/plugins/us_states/)

And rails provides country\_select to select from a list of countries.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 2, 2008, 9:57pm UTC](https://www.ruby-forum.com/t/need-a-zip-postal-code-database-or-plugin-for-rails/127885/6 "2008-02-02T21:57:10Z")

</div>

To be honest, what I was more in need for is a db or a plugin for  
country/state drop down…  
But since I don’t know how my app is going to evolve, I tought it’d be  
better to get  
the full thing now (zip codes etc…). I’ve heard about GeoKit and  
I’ve seen the API,  
its nice but isn’t that a bit too much, since I don’t plan to be  
making a map app???  
What could you suggest me ??? thx for your time.

On Feb 2, 12:22 am, Nathan E. \<rails-mailing-l…@andreas-
