So, having been able to tinker around with this for a few days I have come up with a couple solutions. The first was really hacky, but accomplished what I needed. My second solution is much more elegant and works great from what I have been able to tell so far! I hope others find this useful.
I handle all of the logic in my controller in just a few lines.
geocoded_by :address
after_validation :geocode, if: ->(obj){ obj.address.present? and obj.address_changed? }
after_validation :lat_changed?
after_save :set_popup_value
private
# This is used to make sure that our address is actually parsed properly and we
# get a valuable lat/long
def lat_changed?
if (self.address_changed?)
if !(self.latitude_changed?)
self.errors.add(:address, "is not valid")
return false
end
end
return true
end
By creating another after_validation
after my geocode, I am able to check if the appropriate values changed, and if they changed in a certain way, than I know there was an issue in the geocoding.
If the address changed, but the latitude didnt change, than you know that when the address got put through geocoder that it didn't get a returned lat/long. And if that is the case then we just add an error to throw to the user and return false, which stops the save to the database.
I hope others with this issue are able to find this post!