Pinas
This gem provides hierarchical listing of Philippine location.
Installation
Add this line to your application's Gemfile:
gem 'pinas'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pinas
Setup
$ rails g pinas:install
$ rake db:migrate
$ rake pinas:load_data
Usage/Sample
The gem provides ActiveRecord model Pinas::Location in 4 levels of locations
$ # All regions
$ Pinas::Location.regions
$ # All provinces
$ Pinas::Location.provinces
$ # All towns
$ Pinas::Location.towns
$ # All barangays
$ Pinas::Location.barangays
Or you can get sub locations $ # get single location $ batangas_province = Pinas::Location.where(name: 'BATANGAS').first # returns Batangas Province
$ # get all towns in Batangas
$ towns = batangas_province.towns
Caveats
At the moment this gem supports Rails 4.x using Mysql database
Contributing
- Fork it ( https://github.com/pangkalizer/pinas/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request