diff --git a/lib/geocoder/request.rb b/lib/geocoder/request.rb index 5f71d46bc86455f9be4b2771b545a16bf5384653..fe8286b58c559f7d4b1bf8584cb796a3e4234f5f 100644 --- a/lib/geocoder/request.rb +++ b/lib/geocoder/request.rb @@ -5,7 +5,11 @@ module Geocoder def location unless defined?(@location) - @location = Geocoder.search(ip).first + if env.has_key?('HTTP_X_REAL_IP') + @location = Geocoder.search(env['HTTP_X_REAL_IP']).first + else + @location = Geocoder.search(ip).first + end end @location end