Forum: Ruby on Rails Which country did a user request come from? How can I determ

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Greg H. (Guest)
on 2007-01-19 17:29
(Received via mailing list)

Can anybody recommend a means to determine the country that an incoming
request is originating from?

I'm guessing that you would first get the IP from the HTTP header and
somehow translate this?  Is there a service that can be used for this?
there a set of rules that one can use to implement within your rails
application?   Any advice welcome, even if the best possible is only a
accuracy thing.

Thanks in advance
Greg H. (Guest)
on 2007-01-19 17:31
(Received via mailing list)
PS  Meant to ask too whether a rails plugin exists for this, and whether
this can be done for free (i.e. without having to pay to subscribe to a
Elad M. (Guest)
on 2007-09-26 00:38
(Received via mailing list)
Yap, use GeoIP gem (look in the free version will
reply to you with a country.

works great, i use it myself in one project.
Dan K. (Guest)
on 2007-09-26 00:40
(Received via mailing list)
Any idea why the following fails?

$ ls -l /usr/share/GeoIP/GeoIP.dat
-rwxr-xr-x   1 root  wheel  682474 Jan 13 09:17

$ cat a.rb
require 'geoip'

$ RUBYOPT=rubygems ruby a.rb
`getaddress': getaddrinfo: No address associated with nodename
/usr/lib/ruby/gems/1.8/gems/geoip-0.3.0/lib/geoip.rb:273:in `country'
        from a.rb:2
Dan K. (Guest)
on 2007-09-26 00:46
(Received via mailing list)
(Replying to self).  The problem is that does not
exist.  The code works with existing sites.  Sorry for the confusion...
Greg H. (Guest)
on 2007-09-26 01:11
(Received via mailing list)
thanks for the reply Elad - I'll have a look right now - how accurate do
find to be?
This topic is locked and can not be replied to.