https://github.com/varvet/freegeoip-rails
Rails engine with IP geolocation API like Freegeoip
https://github.com/varvet/freegeoip-rails
Last synced: about 2 months ago
JSON representation
Rails engine with IP geolocation API like Freegeoip
- Host: GitHub
- URL: https://github.com/varvet/freegeoip-rails
- Owner: varvet
- License: mit
- Created: 2018-02-12T09:25:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-13T20:57:15.000Z (over 6 years ago)
- Last Synced: 2025-07-11T05:39:45.333Z (3 months ago)
- Language: Ruby
- Size: 34.2 KB
- Stars: 1
- Watchers: 8
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/varvet/freegeoip-rails)
# Freegeoip
This gem provides a simple Rails engine with an IP geolocation API that ducks with [Freegeoip](https://github.com/fiorix/freegeoip).
It reads MaxMindDB's open source GeoLite2 City database, with the help of [maxminddb](https://github.com/yhirose/maxminddb) gem, a pure Ruby implementation.
You can find MaxMind's GeoLite2 City database [here](https://dev.maxmind.com/geoip/geoip2/geolite2/).
## Installation
Add this line to your application's Gemfile:
```ruby
gem "freegeoip-rails", require: "freegeoip"
```Mount the engine in your routes file:
```ruby
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:
```ruby
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](https://www.varvet.com/).
Skapad med omsorg av [Varvet digital byrå](https://www.varvet.se/).## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).