codahale.com٭blog

This is my old blog. My current writing is here: codahale.com

USPS countries list for Rails

Yes, I’m going to be rolling out quite a few Rails plugins for the next few weeks; I’ve got a bit of a backlog.

This one replaces the list of countries used by country_select and other Rails helpers with a list of countries that the United States Postal Service can send mail to. (Yes, it’s hopelessly US-centric, and I know that many countries don’t self-identify as these terms, but it’s not for use by demographers, it’s for use when you need people to specify where they want something mailed via Lance Armstrong’s old team.) The reason I put this together is to make it integrate nicely with the USPS’s shipping quote web service.

Installation

For the svn-happy:


./script/plugin install -x http://svn.codahale.com/usps_countries/trunk

For the Subversionally challenged:


./script/plugin install http://svn.codahale.com/usps_countries/trunk

Usage

This really just replaces the country listings. The one thing you’ll want to know is that the listing for the US can be found here:


USPSCountries::UNITED_STATES

There you go!

3 Responses to “USPS countries list for Rails”

  1. Ian Connor Says:

    This is a plugin that I use - thanks for the good work.
    I did have an issue deploying when your svn server was down but found piston to help here and followed these instructions:
    http://clarkware.com/cgi/blosxom/2007/01/22
    This will help me control when I update from you and also leave your svn server alone while I am deploying.

  2. Tim Matheson Says:

    I dont get it. Where the hell do you put the USPSCountries::UNITED_STATES in your application? I am fairly new to rails could you be more specific?

  3. Ed Zerylnick Says:

    This is a very useful list! And it can get out of date — Kosovo became its own nation just the other day, for example. So, I am looking for an official USPS download of countries available on the web that is kept up to date.
    Is there such a thing? How did you get this data?
    Thanks for the help.