Skip to content

IP2Location.io Ruby on Rails library enables user to query for an enriched geolocation data set of an IP address using IP2Location.io IP Geolocation API.

License

Notifications You must be signed in to change notification settings

ip2location/ip2location-io-rails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IP2Location.io Ruby on Rails Library

This IP2Location.io Ruby on Rails library enables user to query for an enriched data set, such as country, region, district, city, latitude & longitude, ZIP code, time zone, ASN, ISP, domain, net speed, IDD code, area code, weather station data, MNC, MCC, mobile brand, elevation, usage type, address type, advertisement category and proxy data with an IP address. It supports both IPv4 and IPv6 address lookup.

This module requires API key to function. You may sign up for a free API key at https://www.ip2location.io/pricing.

INSTALLATION

  1. Add this lines to your application's Gemfile:
gem 'ip2location_io_ruby'
gem 'ip2location_io_rails'
  1. Then execute it
$ bundle install
  1. Open the preferred file in the config/environments directory. Add the following code to the chosen configuration file after the Rails.application.configure do line.
config.ip2location_io_key = 'YOUR_API_KEY'

USAGE

  1. Create a TestController using the below command line
bin/rails generate controller Test index --skip-routes
  1. Open the app/controllers/test_controller.rb in any text editor.
  2. Add the below lines into the controller file.
require 'ip2location_io_rails'

class TestController < ApplicationController
  def index
    location_service = Ip2locationIORails.new('8.8.8.8')
    @location = location_service.location.body
  end
end
  1. Open the app/views/test/index.html.erb in any text editor and add the below lines into it.
<p>IP2Location.io data for IP 8.8.8.8: <%= @location %></p>
  1. Add the following line into the config/routes.rb file after the Rails.application.routes.draw do line.
get "/test", to: "test#index"
  1. Restart your development server.
$ bin/rails server
  1. Enter the URL /test and run. You should see the proxy information of 8.8.8.8 IP address.

Support

Email: support@ip2location.com URL: https://www.ip2location.com

About

IP2Location.io Ruby on Rails library enables user to query for an enriched geolocation data set of an IP address using IP2Location.io IP Geolocation API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages