I have the following code in my User model.
geocoded_by :city
after_validation :geocode, if: ->(user){ user.city.present? and user.city_changed? }
Initially the user does not have to input their city so these users will not be geocoded. Is there an way to run conditional code on a call back, so if no city, geocode by ip_address, if city geocode by city?
I accept this is a basic question but I have had difficulty finding info on applying conditional code to a call back
tried
if self.city.present?
geocoded_by :city
else
geocoded_by :ip_address
end
without success