Skip to content

Instantly share code, notes, and snippets.

@graybill
Created May 4, 2011 21:00
Show Gist options
  • Save graybill/956024 to your computer and use it in GitHub Desktop.
Save graybill/956024 to your computer and use it in GitHub Desktop.
def self.coordinates(addr)
include Geokit::Geocoders
res=MultiGeocoder.geocode(addr)
r = res.ll.split(',')
[r[0].to_f, r[1].to_f]
end
def self.create(params = nil)
loc = coordinates(params[:address1] + "+PA+" + params[:zipcode])
super
end
@brandonhilkert
Copy link

class Matching < ActiveRecord::Base

before_create :set_location

private

def set_location
self.loc = coordinates(params[:address1] + "+PA+" + params[:zipcode])
end

def coordinates(addr)
include Geokit::Geocoders
res=MultiGeocoder.geocode(addr)
r = res.ll.split(',')
[r[0].to_f, r[1].to_f]
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment