{"id":22306552,"url":"https://github.com/ip2location/ip2location-rails","last_synced_at":"2026-04-24T23:34:46.866Z","repository":{"id":265709307,"uuid":"892354909","full_name":"ip2location/ip2location-rails","owner":"ip2location","description":"IP2Location Ruby on Rails library that enables the user to find the geolocation of an IP address using IP2Location BIN database.","archived":false,"fork":false,"pushed_at":"2025-02-18T00:50:08.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T01:52:21.269Z","etag":null,"topics":["geolocation","geolocation-database","ip2location","ip2location-database","ruby-gem","ruby-on-rails"],"latest_commit_sha":null,"homepage":"https://www.ip2location.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ip2location.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-22T00:37:14.000Z","updated_at":"2025-02-18T00:50:12.000Z","dependencies_parsed_at":"2024-12-02T07:15:33.142Z","dependency_job_id":null,"html_url":"https://github.com/ip2location/ip2location-rails","commit_stats":null,"previous_names":["ip2location/ip2location-rails"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ip2location","download_url":"https://codeload.github.com/ip2location/ip2location-rails/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245622926,"owners_count":20645677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geolocation","geolocation-database","ip2location","ip2location-database","ruby-gem","ruby-on-rails"],"created_at":"2024-12-03T19:27:54.515Z","updated_at":"2026-04-24T23:34:46.842Z","avatar_url":"https://github.com/ip2location.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://img.shields.io/gem/v/ip2location_rails.svg)](https://rubygems.org/gems/ip2location_rails)\n[![Total Downloads](https://img.shields.io/gem/dt/ip2location_rails.svg)](https://rubygems.org/gems/ip2location_rails)\n\n# IP2Location Ruby on Rails Library\nThis is IP2Location Ruby on Rails library that enables the user to find the country, region or state, district, city, latitude and longitude, ZIP/Postal code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type, IAB category and ASN from IP address using IP2Location database.  The library reads the geo location information from **IP2Location BIN data** file.\n\nSupported IPv4 and IPv6 address.\n\n## INSTALLATION\n1. Add this lines to your application's Gemfile:\n```ruby\ngem 'ip2location_ruby'\ngem 'ip2location_rails'\n```\n2. Then execute it\n```bash\n$ bundle install\n```\n3. 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.\n```ruby\nconfig.ip2location_db_path = Rails.root.join('lib', 'assets', 'ip2location_rails', 'IP2LOCATION.BIN').to_s\n```\n\n## USAGE\n1. Download IP2Location BIN database\n    - IP2Location free LITE database at https://lite.ip2location.com\n    - IP2Location commercial database at https://www.ip2location.com\n2. Create a folder named as `ip2location_rails` in the `lib/assets` directory.\n3. Unzip and copy the BIN file into `lib/assets/ip2location_rails` folder.\n4. Rename the BIN file to **IP2LOCATION.BIN**.\n5. Create a **TestController** using the below command line\n```bash\nbin/rails generate controller Test index --skip-routes\n```\n6. Open the *app/controllers/test_controller.rb* in any text editor.\n7. Add the below lines into the controller file.\n```ruby\nrequire 'ip2location_rails'\n\nclass TestController \u003c ApplicationController\n  def index\n    location_service = Ip2locationRails.new('8.8.8.8')\n    @country_code = location_service.country_code\n    @country_name = location_service.country_name\n    @region = location_service.region\n    @city = location_service.city\n    @latitude = location_service.latitude\n    @longitude = location_service.longitude\n    @isp = location_service.isp\n    @domain = location_service.domain\n    @netspeed = location_service.netspeed\n    @area_code = location_service.areacode\n    @idd_code = location_service.iddcode\n    @time_zone = location_service.timezone\n    @zip_code = location_service.zipcode\n    @weather_station_name = location_service.weatherstationname\n    @weather_station_code = location_service.weatherstationcode\n    @mcc= location_service.mcc\n    @mnc = location_service.mnc\n    @mobile_brand = location_service.mobilebrand\n    @elevation = location_service.elevation\n    @usage_type = location_service.usagetype\n    @address_type = location_service.addresstype\n    @category = location_service.category\n    @district = location_service.district\n    @asn = location_service.asn\n    @as = location_service.as\n  end\nend\n```\n8. Open the *app/views/test/index.html.erb* in any text editor and add the below lines into it.\n```\n\u003cp\u003eCountry Code: \u003c%= @country_code %\u003e\u003c/p\u003e\n\u003cp\u003eCountry Name: \u003c%= @country_name %\u003e\u003c/p\u003e\n\u003cp\u003eRegion Name: \u003c%= @region %\u003e\u003c/p\u003e\n\u003cp\u003eCity Name: \u003c%= @city %\u003e\u003c/p\u003e\n\u003cp\u003eLatitude: \u003c%= @latitude %\u003e\u003c/p\u003e\n\u003cp\u003eLongitude: \u003c%= @longitude %\u003e\u003c/p\u003e\n\u003cp\u003eISP Name: \u003c%= @isp %\u003e\u003c/p\u003e\n\u003cp\u003eDomain Name: \u003c%= @domain %\u003e\u003c/p\u003e\n\u003cp\u003eNet Speed: \u003c%= @netspeed %\u003e\u003c/p\u003e\n\u003cp\u003eArea Code: \u003c%= @area_code %\u003e\u003c/p\u003e\n\u003cp\u003eIDD Code: \u003c%= @idd_code %\u003e\u003c/p\u003e\n\u003cp\u003eTime Zone: \u003c%= @time_zone %\u003e\u003c/p\u003e\n\u003cp\u003eZIP Code: \u003c%= @zip_code %\u003e\u003c/p\u003e\n\u003cp\u003eWeather Station Code: \u003c%= @weather_station_name %\u003e\u003c/p\u003e\n\u003cp\u003eWeather Station Name: \u003c%= @weather_station_code %\u003e\u003c/p\u003e\n\u003cp\u003eMCC: \u003c%= @mcc %\u003e\u003c/p\u003e\n\u003cp\u003eMNC: \u003c%= @mnc %\u003e\u003c/p\u003e\n\u003cp\u003eMobile Carrier: \u003c%= @mobile_brand %\u003e\u003c/p\u003e\n\u003cp\u003eElevation: \u003c%= @elevation %\u003e\u003c/p\u003e\n\u003cp\u003eUsage Type: \u003c%= @usage_type %\u003e\u003c/p\u003e\n\u003cp\u003eAddress Type: \u003c%= @address_type %\u003e\u003c/p\u003e\n\u003cp\u003eCategory: \u003c%= @category %\u003e\u003c/p\u003e\n\u003cp\u003eDistrict: \u003c%= @district %\u003e\u003c/p\u003e\n\u003cp\u003eASN: \u003c%= @asn %\u003e\u003c/p\u003e\n\u003cp\u003eAS: \u003c%= @as %\u003e\u003c/p\u003e\n```\n9. Add the following line into the *config/routes.rb* file after the `Rails.application.routes.draw do` line.\n```ruby\nget \"/test\", to: \"test#index\"\n```\n10. Restart your development server.\n```bash\n$ bin/rails server\n```\n11. Enter the URL \u003cyour domain\u003e/test and run. You should see the information of **8.8.8.8** IP address.\n\n## Dependencies\nThis library requires IP2Location BIN data file to function. You may download the BIN data file at\n* IP2Location LITE BIN Data (Free): https://lite.ip2location.com\n* IP2Location Commercial BIN Data (Comprehensive): https://www.ip2location.com\n\n## IPv4 BIN vs IPv6 BIN\n* Use the IPv4 BIN file if you just need to query IPv4 addresses.\n* Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.\n\n## Support\nEmail: support@ip2location.com\nURL: [https://www.ip2location.com](https://www.ip2location.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fip2location%2Fip2location-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-rails/lists"}