Giter Site home page Giter Site logo

rails's Introduction

IPinfo IPinfo Rails Client Library

This is the official Rails client library for the IPinfo.io IP address API, allowing you to look up your own IP address, or get any of the following details for an IP:

  • Geolocation (city, region, country, postal code, latitude, and longitude)
  • ASN (ISP or network operator, associated domain name, and type, such as business, hosting, or company)
  • Company (the name and domain of the business that uses the IP address)
  • Carrier (the name of the mobile carrier and MNC and MCC for that carrier if the IP is used exclusively for mobile traffic)

Check all the data we have for your IP address here.

Getting Started

You'll need an IPinfo API access token, which you can get by signing up for a free account at https://ipinfo.io/signup.

The free plan is limited to 50,000 requests per month, and doesn't include some of the data fields such as IP type and company data. To enable all the data fields and additional request volumes see https://ipinfo.io/pricing

Installation

  1. Option 1) Add this line to your application's Gemfile:

    gem 'ipinfo-rails'

    Then execute:

    $ bundle install

    Option 2) Install it yourself by running the following command:

    $ gem install ipinfo-rails
  2. Open your config/environment.rb file or your preferred file in the config/environment directory. Add the following code to your chosen configuration file.

    require 'ipinfo-rails'
    config.middleware.use(IPinfoMiddleware, {token: "<your_token>"})

    Note: if editing config/environment.rb, this needs to come before Rails.application.initialize! and with Rails.application. prepended to config, otherwise you'll get runtime errors.

  3. Restart your development server.

Quickstart

Once configured, ipinfo-rails will make IP address data accessible within Rail's request object. These values can be accessed at request.env['ipinfo'].

Details Data

request.env['ipinfo'] is Response object that contains all fields listed IPinfo developer docs with a few minor additions. Properties can be accessed through methods of the same name.

request.env['ipinfo'].hostname == 'cpe-104-175-221-247.socal.res.rr.com'

Country Name

request.env['ipinfo'].country_name will return the country name, as supplied by the countries.json file. See below for instructions on changing that file for use with non-English languages. request.env['ipinfo'].country will still return country code.

request.env['ipinfo'].country == 'US'
request.env['ipinfo'].country_name == 'United States'

IP Address

request.env['ipinfo'].ip_address will return the an IPAddr object from the Ruby Standard Library. request.env['ipinfo'].ip will still return a string.

request.env['ipinfo'].ip == '104.175.221.247'
request.env['ipinfo'].ip_address == <IPAddr: IPv4:104.175.221.247/255.255.255.255>

Longitude and Latitude

request.env['ipinfo'].latitude and request.env['ipinfo'].longitude will return latitude and longitude, respectively, as strings. request.env['ipinfo'].loc will still return a composite string of both values.

request.env['ipinfo'].loc == '34.0293,-118.3570'
request.env['ipinfo'].latitude == '34.0293'
request.env['ipinfo'].longitude == '-118.3570'

Accessing all properties

request.env['ipinfo'].all will return all details data as a hash.

request.env['ipinfo'].all ==
{
:asn => {  :asn => 'AS20001',
           :domain => 'twcable.com',
           :name => 'Time Warner Cable Internet LLC',
           :route => '104.172.0.0/14',
           :type => 'isp'},
:city => 'Los Angeles',
:company => {  :domain => 'twcable.com',
               :name => 'Time Warner Cable Internet LLC',
               :type => 'isp'},
:country => 'US',
:country_name => 'United States',
:hostname => 'cpe-104-175-221-247.socal.res.rr.com',
:ip => '104.175.221.247',
:ip_address => <IPAddr: IPv4:104.175.221.247/255.255.255.255>,
:loc => '34.0293,-118.3570',
:latitude => '34.0293',
:longitude => '-118.3570',
:phone => '323',
:postal => '90016',
:region => 'California'
}

Configuration

In addition to the steps listed in the Installation section, it is possible to configure the library with more detail. The following arguments are allowed and are described in detail below.

require 'ipinfo-rails/ip_selector/xforwarded_ip_selector'

config.middleware.use(IPinfoMiddleware, {
  token: "<your_token>",
  ttl: "",
  maxsize: "",
  cache: "",
  http_client: "",
  countries: "",
  filter: "",
  ip_selector: XForwardedIPSelector,
})

IP Selection Mechanism

By default, the source IP on the request is used as the input to IP geolocation.

Since the actual desired IP may be something else, the IP selection mechanism is configurable.

Here are some built-in mechanisms:

Using a custom IP selector

In case a custom IP selector is required, you may implement the IPSelectorInterface and pass the class to ip_selector in config.

require 'custom-package/custom_ip_selector'

config.middleware.use(IPinfoMiddleware, {
  token: "<your_token>",
  ip_selector: CustomIPSelector,
})

Authentication

The IPinfo library can be authenticated with your IPinfo API token, which is set in the environment file. It also works without an authentication token, but in a more limited capacity.

config.middleware.use(IPinfoMiddleware, {token: '123456789abc'})

Caching

In-memory caching of details data is provided by default via the lrucache gem. This uses an LRU (least recently used) cache with a TTL (time to live) by default. This means that values will be cached for the specified duration; if the cache's max size is reached, cache values will be invalidated as necessary, starting with the oldest cached value.

Modifying cache options

Cache behavior can be modified by setting the ttl and maxsize options.

  • Default maximum cache size: 4096 (multiples of 2 are recommended to increase efficiency)
  • Default TTL: 24 hours (in seconds)
config.middleware.use(IPinfoMiddleware, {
  ttl: 30,
  maxsize: 40
})

Using a different cache

It's possible to use a custom cache by creating a child class of the CacheInterface class and passing this into the handler object with the cache keyword argument. FYI this is known as the Strategy Pattern.

config.middleware.use(IPinfoMiddleware, {:cache => my_fancy_custom_class})

If a custom cache is used the maxsize and ttl settings will not be used.

Using a different HTTP library

Ruby is notorious for having lots of HTTP libraries. While Net::HTTP is a reasonable default, you can set any other that Faraday supports if you prefer.

config.middleware.use(IPinfoMiddleware, {:http_client => my_client})

Don't forget to bundle the custom HTTP library as well.

Internationalization

When looking up an IP address, the response object includes a Details.country_name method which includes the country name based on American English. It is possible to return the country name in other languages by setting the countries setting when creating the IPinfo object.

The file must be a .json file with the following structure:

{
 "BD": "Bangladesh",
 "BE": "Belgium",
 "BF": "Burkina Faso",
 "BG": "Bulgaria"
 ...
}
config.middleware.use(IPinfoMiddleware, {:countries => <path_to_settings_file>})

Filtering

By default, ipinfo-rails filters out requests that have bot or spider in the user-agent. Instead of looking up IP address data for these requests, the request.env['ipinfo'] attribute is set to nil. This is to prevent you from unnecessarily using up requests on non-user traffic.

To set your own filtering rules, thereby replacing the default filter, you can set :filter to your own, custom callable function which satisfies the following rules:

  • Accepts one request.
  • Returns True to filter out, False to allow lookup

To use your own filter rules:

config.middleware.use(IPinfoMiddleware, {
  filter: ->(request) {request.ip == '127.0.0.1'}
})

This simple lambda function will filter out requests coming from your local computer.

Other Libraries

There are official IPinfo client libraries available for many languages including PHP, Go, Java, Ruby, and many popular frameworks such as Django, Rails, and Laravel. There are also many third-party libraries and integrations available for our API.

About IPinfo

Founded in 2013, IPinfo prides itself on being the most reliable, accurate, and in-depth source of IP address data available anywhere. We process terabytes of data to produce our custom IP geolocation, company, carrier, privacy detection (VPN, proxy, Tor), hosted domains, and IP type data sets. Our API handles over 40 billion requests a month for 100,000 businesses and developers.

image

rails's People

Contributors

abdullahdevrel avatar deltwalrus avatar jhtimmins avatar rm-umar avatar st-polina avatar umanshahzad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rails's Issues

Add optional IP selection handler

Add an optional IP selection handler to the SDK client initialization step which accepts the request context and expects returning an IP.

The default handler, if no handler is specified by the user, will simply return the IP attached to the request object.

An additional handler should be available within the library, which looks into the X-Forwarded-For header and gets the first IP in the list if it exists, falling back to the IP attached to the request if the header isn't available. This is an implementation that users can optionally use instead of making their own.

Setup Error

Hi Team, just starting to use this gem, following the instructions, i get the following ...

System : Windows 10, Ruby 2.6.6, Rails 6.0.3

added to gemfile gem 'ipinfo-rails'

Thanks in advance
Any help would be appreciated

bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 13.0.1
Using multipart-post 2.1.1  
Using faraday 0.17.3        
Using json 2.3.1
Fetching PriorityQueue 0.1.2
Installing PriorityQueue 0.1.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/PriorityQueue-0.1.2/ext/priority_queue   
C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/2.6.0 -r
./siteconf20201125-28200-ycxfbe.rb extconf.rb
creating Makefile

current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/PriorityQueue-0.1.2/ext/priority_queue   
make "DESTDIR=" clean

current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/PriorityQueue-0.1.2/ext/priority_queue   
make "DESTDIR="
generating CPriorityQueue-x64-mingw32.def
compiling priority_queue.c
In file included from C:/Ruby26-x64/include/ruby-2.6.0/ruby.h:33,
                 from priority_queue.c:24:
priority_queue.c: In function 'pq_push':
priority_queue.c:512:40: warning: cast from pointer to integer of different size
[-Wpointer-to-int-cast]
512 |   rb_hash_aset(hash, object, ULONG2NUM((unsigned long) n)); // TODO:      
This is hackish, maybe its better to also wrap the nodes.
      |                                        ^
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1615:45: note: in definition of    
macro 'RB_ULONG2NUM'
 1615 | #define RB_ULONG2NUM(x) rb_ulong2num_inline(x)
      |                                             ^
priority_queue.c:512:30: note: in expansion of macro 'ULONG2NUM'
512 |   rb_hash_aset(hash, object, ULONG2NUM((unsigned long) n)); // TODO:      
This is hackish, maybe its better to also wrap the nodes.
      |                              ^~~~~~~~~
priority_queue.c: In function 'pq_change_priority':
priority_queue.c:700:39: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
700 |     priority_queue_change_priority(q, (priority_node*) NUM2ULONG(node),   
priority);
      |                                       ^
priority_queue.c: In function 'pq_get_priority':
priority_queue.c:726:22: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
726 |     return (VALUE) (((priority_node*)
NUM2ULONG(node_pointer))->priority);
      |                      ^
priority_queue.c: In function 'pq_delete':
priority_queue.c:788:24: warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]
  788 |     priority_node* n = (priority_node*) NUM2ULONG(node_pointer);        
      |                        ^
In file included from C:/Ruby26-x64/include/ruby-2.6.0/ruby.h:33,
                 from priority_queue.c:24:
priority_queue.c: In function 'pq_node2dot':
priority_queue.c:809:14: warning: cast from pointer to integer of different size
[-Wpointer-to-int-cast]
  809 |    ULONG2NUM((unsigned long) n), n->object, n->priority));
      |              ^
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:2599:35: note: in definition of    
macro 'rb_funcall'
 2599 |  const VALUE rb_funcall_args[] = {__VA_ARGS__}; \
      |                                   ^~~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1630:22: note: in expansion of     
macro 'RB_ULONG2NUM'
 1630 | #define ULONG2NUM(x) RB_ULONG2NUM(x)
      |                      ^~~~~~~~~~~~
priority_queue.c:809:4: note: in expansion of macro 'ULONG2NUM'
  809 |    ULONG2NUM((unsigned long) n), n->object, n->priority));
      |    ^~~~~~~~~
priority_queue.c:813:14: warning: cast from pointer to integer of different size
[-Wpointer-to-int-cast]
  813 |    ULONG2NUM((unsigned long) n), n->object, n->priority));
      |              ^
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:2599:35: note: in definition of
macro 'rb_funcall'
 2599 |  const VALUE rb_funcall_args[] = {__VA_ARGS__}; \
      |                                   ^~~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1630:22: note: in expansion of
macro 'RB_ULONG2NUM'
 1630 | #define ULONG2NUM(x) RB_ULONG2NUM(x)
      |                      ^~~~~~~~~~~~
priority_queue.c:813:4: note: in expansion of macro 'ULONG2NUM'
  813 |    ULONG2NUM((unsigned long) n), n->object, n->priority));
      |    ^~~~~~~~~
priority_queue.c:821:16: warning: cast from pointer to integer of different size
[-Wpointer-to-int-cast]
  821 |      ULONG2NUM((unsigned long) n), ULONG2NUM((unsigned long) n1)));
      |                ^
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:2599:35: note: in definition of
macro 'rb_funcall'
 2599 |  const VALUE rb_funcall_args[] = {__VA_ARGS__}; \
      |                                   ^~~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1630:22: note: in expansion of
macro 'RB_ULONG2NUM'
 1630 | #define ULONG2NUM(x) RB_ULONG2NUM(x)
      |                      ^~~~~~~~~~~~
priority_queue.c:821:6: note: in expansion of macro 'ULONG2NUM'
  821 |      ULONG2NUM((unsigned long) n), ULONG2NUM((unsigned long) n1)));
      |      ^~~~~~~~~
priority_queue.c:821:46: warning: cast from pointer to integer of different size
[-Wpointer-to-int-cast]
  821 |      ULONG2NUM((unsigned long) n), ULONG2NUM((unsigned long) n1)));
      |                                              ^
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:2599:35: note: in definition of
macro 'rb_funcall'
 2599 |  const VALUE rb_funcall_args[] = {__VA_ARGS__}; \
      |                                   ^~~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1630:22: note: in expansion of
macro 'RB_ULONG2NUM'
 1630 | #define ULONG2NUM(x) RB_ULONG2NUM(x)
      |                      ^~~~~~~~~~~~
priority_queue.c:821:36: note: in expansion of macro 'ULONG2NUM'
  821 |      ULONG2NUM((unsigned long) n), ULONG2NUM((unsigned long) n1)));
      |                                    ^~~~~~~~~
In file included from C:/Ruby26-x64/include/ruby-2.6.0/ruby.h:33,
                 from priority_queue.c:24:
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: error: call to
'rb_varargs_bad_length' declared with attribute error:  argument length doesn't
match
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: note: in definition of
macro 'rb_varargs_argc_check'
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~
priority_queue.c:820:4: note: in expansion of macro 'rb_funcall'
  820 |    rb_funcall(Qnil, id_format, 4, rb_str_new2("NODE%i -> NODE%i;\n"),
      |    ^~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: error: call to
'rb_varargs_bad_length' declared with attribute error:  argument length doesn't
match
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: note: in definition of
macro 'rb_varargs_argc_check'
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~
priority_queue.c:820:4: note: in expansion of macro 'rb_funcall'
  820 |    rb_funcall(Qnil, id_format, 4, rb_str_new2("NODE%i -> NODE%i;\n"),
      |    ^~~~~~~~~~
In function 'pq_node2dot',
    inlined from 'pq_node2dot' at priority_queue.c:817:7,
    inlined from 'pq_to_dot' at priority_queue.c:841:7:
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: error: call to
'rb_varargs_bad_length' declared with attribute error:  argument length doesn't
match
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: note: in definition of
macro 'rb_varargs_argc_check'
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~
priority_queue.c:820:4: note: in expansion of macro 'rb_funcall'
  820 |    rb_funcall(Qnil, id_format, 4, rb_str_new2("NODE%i -> NODE%i;\n"),
      |    ^~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: error: call to
'rb_varargs_bad_length' declared with attribute error:  argument length doesn't
match
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: note: in definition of
macro 'rb_varargs_argc_check'
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~
priority_queue.c:820:4: note: in expansion of macro 'rb_funcall'
  820 |    rb_funcall(Qnil, id_format, 4, rb_str_new2("NODE%i -> NODE%i;\n"),
      |    ^~~~~~~~~~
In function 'pq_node2dot',
    inlined from 'pq_to_dot' at priority_queue.c:841:7:
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: error: call to
'rb_varargs_bad_length' declared with attribute error:  argument length doesn't
match
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: note: in definition of
macro 'rb_varargs_argc_check'
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~
priority_queue.c:820:4: note: in expansion of macro 'rb_funcall'
  820 |    rb_funcall(Qnil, id_format, 4, rb_str_new2("NODE%i -> NODE%i;\n"),
      |    ^~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: error: call to
'rb_varargs_bad_length' declared with attribute error:  argument length doesn't
match
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Ruby26-x64/include/ruby-2.6.0/ruby/ruby.h:1850:3: note: in definition of
macro 'rb_varargs_argc_check'
 1850 |   rb_varargs_bad_length(argc, vargc)), \
      |   ^~~~~~~~~~~~~~~~~~~~~
priority_queue.c:820:4: note: in expansion of macro 'rb_funcall'
  820 |    rb_funcall(Qnil, id_format, 4, rb_str_new2("NODE%i -> NODE%i;\n"),
      |    ^~~~~~~~~~
make: *** [Makefile:244: priority_queue.o] Error 1

make failed, exit code 2

Gem files will remain installed in
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/PriorityQueue-0.1.2 for inspection.
Results logged to
C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/PriorityQueue-0.1.2/gem_make.out

An error occurred while installing PriorityQueue (0.1.2), and Bundler cannot
continue.
Make sure that `gem install PriorityQueue -v '0.1.2' --source
'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  ipinfo-rails was resolved to 0.1.1, which depends on
    IPinfo was resolved to 0.1.2, which depends on
      lrucache was resolved to 0.1.4, which depends on
        PriorityQueue

Middleware not loading

Tried completing your steps to install, but got the below error:

Gemfile:

# frozen_string_literal: true

source 'https://rubygems.org'

ruby '2.6.3'

gem 'bootsnap', '>= 1.1.0', require: false
gem 'coffee-rails', '~> 4.2'
gem 'jbuilder', '~> 2.5'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.11'
gem 'rails', '~> 5.2.3'
gem 'sass-rails', '~> 5.0'
gem 'turbolinks', '~> 5'
gem 'uglifier', '>= 1.3.0'
gem 'ipinfo-rails'
...

config/environment.rb:

require 'ipinfo-rails'

# Load the Rails application.
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!

# Rails.application.config.middleware.use(IPinfoMiddleware, {token: ENV['IP_INFO_API_KEY']})

When I run rails s

=> Booting Puma
=> Rails 5.2.3 application starting in development
=> Run `rails server -h` for more startup options
Exiting
Traceback (most recent call last):
  54: from bin/rails:3:in `<main>'
  53: from bin/rails:3:in `load'
  52: from bin/spring:15:in `<top (required)>'
  51: from bin/spring:15:in `require'
  50: from ~/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
  49: from ~/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
  48: from ~/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
  47: from ~/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
  46: from ~/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
  45: from ~/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
  44: from ~/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
  43: from ~/dev/caravan-app/bin/rails:9:in `<top (required)>'
  42: from ~/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
  41: from ~/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
  40: from ~/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
  39: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
  38: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
  37: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
  36: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
  35: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
  34: from ~/.rvm/gems/ruby-2.6.3/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<main>'
  33: from ~/.rvm/gems/ruby-2.6.3/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
  32: from ~/.rvm/gems/ruby-2.6.3/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
  31: from ~/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
  30: from ~/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
  29: from ~/.rvm/gems/ruby-2.6.3/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
  28: from ~/.rvm/gems/ruby-2.6.3/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:142:in `perform'
  27: from ~/.rvm/gems/ruby-2.6.3/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:142:in `tap'
  26: from ~/.rvm/gems/ruby-2.6.3/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:147:in `block in perform'
  25: from ~/.rvm/gems/ruby-2.6.3/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:51:in `start'
  24: from ~/.rvm/gems/ruby-2.6.3/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:89:in `log_to_stdout'
  23: from ~/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/server.rb:354:in `wrapped_app'
  22: from ~/.rvm/gems/ruby-2.6.3/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:27:in `app'
  21: from ~/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/server.rb:219:in `app'
  20: from ~/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/server.rb:319:in `build_app_and_options_from_config'
  19: from ~/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/builder.rb:40:in `parse_file'
  18: from ~/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/builder.rb:49:in `new_from_string'
  17: from ~/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/builder.rb:49:in `eval'
  16: from config.ru:in `<main>'
  15: from config.ru:in `new'
  14: from ~/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/builder.rb:55:in `initialize'
  13: from ~/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/builder.rb:55:in `instance_eval'
  12: from config.ru:5:in `block in <main>'
  11: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `require_relative'
  10: from ~/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
   9: from ~/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
   8: from ~/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
   7: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
   6: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
   5: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
   4: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
   3: from ~/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
   2: from ~/dev/caravan-app/config/environment.rb:11:in `<main>'
   1: from ~/.rvm/gems/ruby-2.6.3/gems/actionpack-5.2.3/lib/action_dispatch/middleware/stack.rb:97:in `use'
~/.rvm/gems/ruby-2.6.3/gems/actionpack-5.2.3/lib/action_dispatch/middleware/stack.rb:97:in `push': can't modify frozen Array (FrozenError)

ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580)
rails -v: Rails 5.2.3

Request is empty

Hi. So, i've just installed and configured the gem. Tremendous work and works perfectly. However, when i try to print the attributes for puts request.env['ipinfo'].all i get the following

{:ip=>"::1", :bogon=>true, :ip_address=>#<IPAddr: IPv6:0000:0000:0000:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>}

I am testing on development mode.

all other attributes are missing. i could not find out where to fix it. what's going wrong? Thanks.

JSON::ParserError

We're using this library and when the IPInfo API returns a 503 response, the handler for IPInfo raises an error because the return from the API is not a JSON, but rather a String which states the following,

unexpected token at 'upstream connect error or disconnect/reset before headers. reset reason: connection timeout' (JSON::ParserError)

I have looked at the code and it seems the ipinfo-rails gem relies on the ipinfo Ruby gem version 1.0.1. But the latest version of the IPInfo ruby gem is 2.2.1.

Any idea why we're keeping the Ruby gem's dependency so low?

Thanks for your answer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.