Sha256: 2526f7906723907e887592ee9a7050b4e409937a412194f6a757460684d7b621
Contents?: true
Size: 622 Bytes
Versions: 11
Compression:
Stored size: 622 Bytes
Contents
module Geocoder module Request def location @location ||= begin detected_ip = env['HTTP_X_REAL_IP'] || ( env['HTTP_X_FORWARDED_FOR'] && env['HTTP_X_FORWARDED_FOR'].split(",").first.strip ) detected_ip = IpAddress.new(detected_ip.to_s) if detected_ip.valid? and !detected_ip.loopback? real_ip = detected_ip.to_s else real_ip = self.ip end Geocoder.search(real_ip).first end @location end end end if defined?(Rack) and defined?(Rack::Request) Rack::Request.send :include, Geocoder::Request end
Version data entries
11 entries across 11 versions & 3 rubygems