This gem provides hierarchical listing of Philippine location.
Add this line to your application's Gemfile:
gem 'pinas'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pinas
$ rails g pinas:install
$ rake db:migrate
$ rake pinas:load_data
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
Get location coordinates
batangas_province.coordinates
Get formatted display
batangas_province.formatted_display
Or you may want to extend the model
class Location < Pinas::Location
end
At the moment this gem only supports Ruby >= 1.9.3, Rails 4.x and ActiveRecord compatible storage
- Write tests
- Support other ORM
- Provide geo-polygons
- 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