Module: IpToCountry::Request
- Defined in:
- lib/ip_to_country/request.rb
Instance Method Summary collapse
Instance Method Details
#geoip ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ip_to_country/request.rb', line 7 def geoip unless defined?(@geoip) if env.has_key?('HTTP_X_REAL_IP') @geoip = IpToCountry::Geoip.by_ip(env['HTTP_X_REAL_IP']) elsif env.has_key?('HTTP_X_FORWARDED_FOR') @geoip = IpToCountry::Geoip.by_ip(env['HTTP_X_FORWARDED_FOR'].split(/\s*,\s*/)[0]) else @geoip = IpToCountry::Geoip.by_ip(remote_ip) end end @geoip end |