Thanks for that, nice little method, this is what I put in:
acts_as_mappable
validates_numericality_of :lat, :lng
before_validation_on_create :generate_geocode
private
def generate_geocode
address = [self.street, self.city, self.location_state,
self.postcode, self.country].join(', ')
geoloc = GeoKit::Geocoders::MultiGeocoder.geocode(address)
errors.add_to_base('Could not geocode address') unless
geoloc.success
self.lat, self.lng = geoloc.lat, geoloc.lng
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---