-1

Im using the geocoder gem. I am looking up zipcodes for addresses.

I have old addresses that I need to run the :reverse_geocode method on, but cannot figure out how to re-run the method on older data. How would I go about doing this?

In other words I want to rerun :reverse_geocode on all addresses that do not have zipcode saved.

Colton Seal
  • 379
  • 2
  • 14

1 Answers1

1

Assuming you're working on Address model:

Address.where(zipcode: nil).find_each(&:reverse_geocode)

Note that I used find_each instead of each because it improves efficiency if you have many records.

Marek Lipka
  • 50,622
  • 7
  • 87
  • 91