Using Rails 3.2, I have the following:
g = Geocoder.search(address)
# if no address found, geocode with latitude and longitude
if g.empty?
g = Geocoder.search(latitude, longitude)
if g.empty?
log.info "Geocode failed for #{latitude}, #{longitude}"
end
else
---save---
end
If the first geocoding with address fails, it will try latitude and longitude. If still fails, then it logs error, else it will save.
Is this a good way to write this code?