0.0
No commit activity in last 3 years
No release in over 3 years
Returns the city, state, country, or language for the current user using IP-API.com.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Where Are You

What does it do?

Returns the location (city, state, or country), or language, for the current request using its IP address (via IP-API.com).

How does it work?

Place the following in your Gemfile:

gem 'where_are_you'

To lookup the current user's city & state, call the following anywhere in a Controller or View:

where_are_you(request.remote_ip)

Examples

You can query a user's city, state, or country:

where_are_you(request.remote_ip) # returns "Chicago, IL"

where_are_you(request.remote_ip, 'city') # also returns "Chicago, IL"
where_are_you(request.remote_ip, 'state') # returns "Illinois"
where_are_you(request.remote_ip, 'country') # returns "United States"
where_are_you(request.remote_ip, 'language') # returns "en"

Language

We support languages for over 250 countries, but if the country is not supported, where_are_you returns nil.

International

By default, international values return 'nil' for city & state queries. To override this (with sometimes odd results) add a third parameter of 'true':

where_are_you(request.remote_ip, 'city', true) # returns "Berlin, 16", "Montréal, QC"
where_are_you(request.remote_ip, 'state', true) # returns "Berlin", "Quebec"
where_are_you(request.remote_ip, 'country') # true is not needed in this case, returns "Germany", "Canada"

Limits

IP-API.com will automatically ban IP addresses with over 150 requests per minute. Visit http://ip-api.com/docs/unban to unban your IP address.