


new ( database: ' /usr/share/GeoIP/GeoIP2-Country.mmdb ', ) record = reader. network # 128.101.101.101/32Ĭountry Example require ' maxmind/geoip2 ' # This creates the Reader object which should be reused across lookups. new ( database: ' /usr/share/GeoIP/GeoIP2-City.mmdb ', ) record = reader. City Example require ' maxmind/geoip2 ' # This creates the Reader object which should be reused across lookups. MaxMind::DB::InvalidDatabaseError exception will be thrown.įor more details. If the record is not found, a MaxMind::GeoIP2::AddressNotFoundErrorĮxception is thrown. Objects for the different parts of the data such as the city in which the This model in turn contains multiple container If the lookup succeeds, the method call will return a model class for the You may then call the method corresponding to the database you With the path to the database file as the first argument to theĬonstructor. To use this API, you must create a new MaxMind::GeoIP2::Reader object Service should not be used to identify a particular address or household. Any location provided by a GeoIP2 database or web Installation gem install maxmind - geoip2 IP Geolocation Usage This is the Ruby API for the GeoIP2 and GeoLite2Īnd databases.
