Repository is archived
No commit activity in last 3 years
No release in over 3 years
Select builder for district of Taiwan cities.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 4.2.3
 Project Readme

TaiwanDistricts

Build Status CircleCI

正體中文

Easy way to build a selector for Taiwan Cities and Districts.

This gem is base on china_city and TaiwanCity.

Support Rails 4.2 and upper version.

Installation

In gemfile

gem 'taiwan_districts', :git => 'https://github.com/bugtender/TaiwanDistricts'

In app/assets/javascripts/application.js

//= require 'jquery'
//= require 'taiwan_districts/jquery.taiwan_districts'

In config/routes.rb

mount TaiwanDistricts::Engine => '/taiwan_districts'

Usage

Add below code to your ERB

Traditional-Chinese

<div class='rails-helper city-group'>
  <%= select_tag :city, 
    options_for_select( TaiwanDistricts.list(lang='zhtw') ),
    prompt: '--縣市--',
    class: ['city-select', 'city-city'], 
    lang: 'zhtw' %>
  <%= select_tag :district, 
    nil, 
    prompt: '--鄉鎮市區--', 
    class: ['city-select', 'city-district'] %>
</div>

English

<div class='rails-helper city-group'>
  <%= select_tag :city, 
    options_for_select( TaiwanDistricts.list(lang='en') ), 
    prompt: '--Cities--', 
    class: ['city-select', 'city-city'], 
    lang: 'en' %>
  <%= select_tag :district, 
    nil, 
    prompt: '--Districts--', 
    class: ['city-select', 'city-district'] %>
</div>

all selector need city-select class. and under the class='city-group' DOM.

Origin districts data

In db/districts.json. If you want to remove some districts that useless. You can fork this gem and remove the data.

The code rule of the city is custom number + 000, and the district is city custom code + zipcode.

Changelog

version 0.1.2

Add TravisCI and auto gem build.

version 0.1.0

It's works. And add some test.

License

MIT

Special Thanks