Project

regions

0.0
No commit activity in last 3 years
No release in over 3 years
Pre-built Rails model with all Regions from Carmen.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 1.0
<= 6, >= 4.2
 Project Readme

Regions

Add a Rails model containing all regions and subregions from Carmen.

Installation

Add the gem to your Gemfile.

gem 'regions'

Bundle Install

bundle install

Migrate to create the table.

rake db:migrate

Import all the regions.

rake regions:import

Usage

Usage is fairly simple, you have access to the Region model. Each region can belong to a region and can have many regions. There is also a Region.countries scope to quickly access the top level of regions.

region = Region.countries.find_by(code: 'US')
 => #<Region id: 4831, region_id: nil, category: "country", code: "US", name: "United States", alpha_3_code: "USA", numeric_code: 840, created_at: "2016-11-21 00:09:01", updated_at: "2016-11-21 00:09:01">
 
region.name
 => "United States"
 
region.regions.first.category
 => "state"
 
region.regions.first.name
 => "Alaska"