Best Zip Code Plugin for Ruby
gem install geokit
In IRB:
require 'geokit'
geo = GeoKit::Geocoders::MultiGeocoder.multi_geocoder('90210')
if geo.success
geo.state # => CA
geo.city # => Beverly Hills
end
All Countries States Cities and Zipcodes in a Application
Thanks Guys,
I got all the the countries and states of all of them, but no zip codes.
http://27.org/isocountrylist/iso_country_list.sql
This contains all countries, and there iso-3166 codes ( Siberia code needs to be changed from "CS" to "RS")
And here is the FIPS file for countries with states
http://www.maxmind.com/app/fips_include
For zip code validation I am using
http://www.geonames.org webservices
There is a geonames ruby gem as well, which makes it really simple to do zipcode validations
Hope that helps anybody who needs this information, worth keeping it handy for web projects.
Another Link ( thanks @laise ): http://dev.maxmind.com/static/csv/codes/maxmind/region.csv
What is the ultimate postal code and zip regex?
There is none.
Postal/zip codes around the world don't follow a common pattern. In some countries they are made up by numbers, in others they can be combinations of numbers an letters, some can contain spaces, others dots, the number of characters can vary from two to at least six...
What you could do (theoretically) is create a seperate regex for every country in the world, not recommendable IMO. But you would still be missing on the validation part: Zip code 12345
may exist, but 12346
not, maybe 12344
doesn't exist either. How do you check for that with a regex?
You can't.
Related Topics
Unable to Load Gem Cocoa Pods While Creating Repo
Checking Whether the C Compiler Works... No
Understanding Ruby Symbol as Method Call
Why Doesn't This Work If in Ruby Everything Is an Object
Ruby Create Recursive Directory Tree
How to Load Some Activerecord Models from a Yaml File and Save Them to the Db
Start or Ensure That Delayed Job Runs When an Application/Server Restarts
Singleton Method VS. Class Method
Ruby on Rails: Yielding Specific Views in a Specific Places in the Layout
Rails 3, Check CSV File Encoding Before Import
Installing Ruby 2.3 on Wsl (Windows Subsystem for Linux)
Polymorphic Association with Multiple Associations on the Same Model
Refactoring a Large Routes.Rb File in Rails 4
Using Multiple Controllers in One View in Rails