-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
42 lines (31 loc) · 1.21 KB
/
README
File metadata and controls
42 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
GeoIp
=====
A dead simple plugin that make use of ipinfodb.com web service to locate incoming request geographic origin.
More information on ip info db : http://ipinfodb.com/
If you use their service a lot, please consider making a donation here: http://ipinfodb.com/donate.php
Example
=======
This plugin add the method "remote_localization(ip = nil)" to ActionController::Base.
If no IP is provided as a parameter, then request.remote_ip is used.
the return value is a hash containing all information found on ipinfodb, i.e.:
{
"RegionName"=>"Brabant",
"Status"=>"OK",
"Longitude"=>"4.3667",
"City"=>"Elsene",
"Gmtoffset"=>"1.0",
"RegionCode"=>"02",
"CountryName"=>"Belgium",
"Latitude"=>"50.8333",
"CountryCode"=>"BE",
"Dstoffset"=>"2.0",
"ZipPostalCode"=>nil,
"Ip"=>"my_office_ip_was_here"
}
You can also configure your environment so that the method returns a predefined value (for test/development use)
in any of your environment file:
GeoIp.configure do |config|
config.default_return_value = {:hello => "world"}
end
This plugin is in production use on http://www.naturesca.com
Copyright (c) 2009 redstorm sprl (http://www.redstorm.be), released under the MIT license