alexreisner/geocoder

Rails geocoder gem address nil

Closed this issue · 1 comments

after setup a simple geocode, i would like to reverse it to get just the city and the state with zip code.
this is the default method all over the internet. Well did not work, the latitude, longitude, and the rest still nil.

but if i not use reverse just geocode by zip get the attributes and the raw complete address.

i even tried to add address.split to see if get the address and split it.

on location model:

geocoded_by :zip     
  reverse_geocoded_by :latitude, :longitude do |obj,results|
    if geo = results.first
        #obj.street  = geo.address.split(',')[0]
        obj.state = geo.state
        obj.city = geo.city
    
    end
  end

  after_validation :reverse_geocode, :if => :zip_changed?

forgot to add after_validation :geocode