Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic location detection in Ruby on Rails

A technical and legal question - what's the best rails gem to auto-detect location of a web visitor via e.g. IP? Down to granularity of state.

And is this an illegal privacy breach? Why do some sites auto-detect location and others ask for manual zip code input?

Thanks in advance!

like image 268
heebee313 Avatar asked Nov 21 '25 22:11

heebee313


1 Answers

You'll need some sort of IP-to-location translation database, like this one:

http://www.maxmind.com/app/ip-location

[Update: free version is here: http://www.maxmind.com/app/geolitecity]

The reason some auto-detect and others don't is a question of reliability. You can't guarantee the IP you're seeing is the actual end users IP (proxies/VPNs/etc cause problems) so while it's fine for general use, it's not practical if you're doing something for example with billing or calculating shipping costs.

like image 119
jvenema Avatar answered Nov 24 '25 18:11

jvenema