0.0
No commit activity in last 3 years
No release in over 3 years
Rails engine with IP geolocation API like Freegeoip
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.7.2

Runtime

>= 4.2
 Project Readme

Build status

Freegeoip

This gem provides a simple Rails engine with an IP geolocation API that ducks with Freegeoip.

It reads MaxMindDB's open source GeoLite2 City database, with the help of maxminddb gem, a pure Ruby implementation.

You can find MaxMind's GeoLite2 City database here.

Installation

Add this line to your application's Gemfile:

gem "freegeoip-rails", require: "freegeoip"

Mount the engine in your routes file:

mount Freegeoip::Engine, at: "/json"

Add an initializer like config/initializers/freegeoip.rb and tell the engine where it can find your GeoLite2 City database:

  Freegeoip.configure do |config|
    # Anything that can be opened by OpenURI
    config.db_location = Rails.root.join "vendor/maxminddb/GeoLite2-City.mmdb"
  end

Start your web server and point your browser to http://localhost:3000/json/www.ruby-lang.org or http://localhost:3000/json/151.101.1.178 and you should get a response with JSON data.

Contributing

Contributions are always welcome.

Varvet

Crafted with love at Varvet digital agency. Skapad med omsorg av Varvet digital byrÄ.

License

The gem is available as open source under the terms of the MIT License.