Created
February 5, 2015 21:16
-
-
Save forrestwilkins/2254846e24bc5da45945 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def current_location | |
geoip = GeoIP.new('GeoLiteCity.dat').city(self.ip) | |
if defined? geoip and geoip | |
self.latitude = geoip.latitude | |
self.longitude = geoip.longitude | |
if latitude and longitude | |
geocoder = Geocoder.search("#{latitude}, #{longitude}").first | |
if geocoder and geocoder.formatted_address | |
self.address = geocoder.formatted_address | |
end | |
end | |
end | |
get_zip if self.zip_code.nil? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment