Class: AuthTrail::GeocodeJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/auth_trail/geocode_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(login_activity) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/jobs/auth_trail/geocode_job.rb', line 3

def perform()
  result =
    begin
      Geocoder.search(.ip).first.try(:data)
    rescue => e
      Rails.logger.info "Geocode failed: #{e.message}"
      nil
    end

  if result
    .update!(
      city: result["city"].presence,
      region: result["region_name"].presence,
      country: result["country_name"].presence
    )
  end
end