Try using maxmind.com - this will do a geo lookup based on IP address. They have a free or paid for database that your store on your server. They have a Ruby API. I use this in a production system and the lookups are typically sub-millisecond as the data is cached.