app/models/venue.rb
# Try to geocode, but don't complain if we can't.
# TODO Consider renaming this to #add_geocoding! to imply that this method makes destructive changes the object, rather than just returning values. Compare its name to the method called #geocode_address, which just returns values.
Try to geocode, but don't complain if we can't.
TODO Consider renaming this to #add_geocoding. to imply that this method makes destructive changes the object, rather than just returning values. Compare its name to the method called #geocode_address, which just returns values.
Try to geocode but don ' t complain if we can ' t . TODO Consider renaming this to #add_geocoding . to imply that this method makes destructive changes the object rather than just returning values . Compare its name to the method called #geocode_address which just returns values .
def geocode
    unless location or geocode_address.blank? or duplicate_of
      geo = GeoKit::Geocoders::MultiGeocoder.geocode(geocode_address)
      if geo.success
        self.latitude       = geo.lat
        self.longitude      = geo.lng
        self.street_address = geo.street_address if self.street_address.blank?
        self.locality       = geo.city           if self.locality.blank?
        self.region         = geo.state          if self.region.blank?
        self.postal_code    = geo.zip            if self.postal_code.blank?
        self.country        = geo.country_code   if self.country.blank?
      end
    end
    return true
  end
def geocode unless location or geocode_address . blank? or duplicate_of geo = GeoKit :: Geocoders :: MultiGeocoder . geocode ( geocode_address ) if geo . success self . latitude = geo . lat self . longitude = geo . lng self . street_address = geo . street_address if self . street_address . blank? self . locality = geo . city if self . locality . blank? self . region = geo . state if self . region . blank? self . postal_code = geo . zip if self . postal_code . blank? self . country = geo . country_code if self . country . blank? end end return true end
Try to geocode, but don't complain if we can't.
Try to geocode but don ' t complain if we can ' t .
# puts "Geocoding #{geo.success ? "successful" : "failed"}: #{geo.inspect}"