app/jobs/auth_trail/geocode_job.rb in authtrail-0.1.1 vs app/jobs/auth_trail/geocode_job.rb in authtrail-0.1.2
- old
+ new
@@ -1,20 +1,20 @@
module AuthTrail
class GeocodeJob < ApplicationJob
def perform(login_activity)
result =
begin
- Geocoder.search(login_activity.ip).first.try(:data)
+ Geocoder.search(login_activity.ip).first
rescue => e
Rails.logger.info "Geocode failed: #{e.message}"
nil
end
if result
login_activity.update!(
- city: result["city"].presence,
- region: result["region_name"].presence,
- country: result["country_name"].presence
+ city: result.try(:city).presence,
+ region: result.try(:state).presence,
+ country: result.try(:country).presence
)
end
end
end
end