vrfs-774: added current_city method

This commit is contained in:
Jonathan Kolyer 2013-11-03 23:42:41 -06:00
parent f192bb8d56
commit b809a75e53
1 changed files with 12 additions and 0 deletions

View File

@ -1011,6 +1011,18 @@ module JamRuby
false
end
def current_city(ip_addy=nil)
unless self.city
if self.lat && self.lng
return MaxMindGeo.where(['lat = ? AND lng = ?',self.lat,self.lng]).limit(1).first.try(:city)
elsif ip_addy
return MaxMindGeo.ip_lookup(ip_addy).try(:city)
end
else
return self.city
end
end
# devise compatibility
#def encrypted_password