City, county, state and postal code models with seed data packaged in a gem for use in Rails.
Add this to your Gemfile:
geo ‘geo’, :git => ‘git@github.com:brenttheisen/geo.git’
Have bundler install and use the gem:
cd <YOUR_RAILS_APP> ; bundle install
Have geo add the table migrations to your app’s migration dir:
rails g geo:install
Run the new migration that will create tables for city, county, state and postal_code:
rake db:migrate
Have geo populate the newly created tables with the seed data it ships with:
rake geo:load_seed
Whew, we’re done…
rails console Geo::City.count
Copyright © 2011 Brent Theisen.