Utilize this YAML file of zip codes to lookup zip-codes in memory. No more unnecessary calls to your database, but you do need to have the necessary ram in your VM.
cp zip_code_lookups.* to your Rails.root/config/initializers
ZIP_CODE.find()
ZIP_CODE.find(‘53012’)
=> {"city"=>"CEDARBURG", “latitude”=>"+43.321475", “county”=>"OZAUKEE", “longitude”=>"-088.004033", “state”=>"WI"}
Have you found this zip code database useful? Well, as you can see, it’s pretty old! Please update me with a newer dataset of zip codes!
Enjoy!