Detecting user's location by his ip address is quite a common task in many web applications. You can find lot's of them in Internet. Here are a short list:
http://hostip.info/
http://ipinfodb.com/
http://www.wipmania.com/
All of them have pretty simple interface. Here is a ruby wrapper for that http://github.com/balepc/ip_geolocation