All Projects → encoreshao → china_regions

encoreshao / china_regions

Licence: MIT license
Ruby Library for China Regions

Programming Languages

ruby
36898 projects - #4 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to china regions

oracle-geo-data
demo.insum.ca/ords/f?p=131
Stars: ✭ 20 (-13.04%)
Mutual labels:  countries, cities
geo-sql-database
Continents, Sub-Continents, Countries, States, Cities, Timezones, Currencies SQL database.
Stars: ✭ 30 (+30.43%)
Mutual labels:  countries, cities
countriesNowAPI
CountriesNow is an Open source API for retrieving geo-information for countries, including their states, cities, population, etc. 🌎
Stars: ✭ 78 (+239.13%)
Mutual labels:  countries, cities
World Cities
Multilingual list of countries, states & cities in XML format. 世界所有城市,国内所有省、市、区、县信息(2020.06)
Stars: ✭ 64 (+178.26%)
Mutual labels:  countries, china
China
🇨🇳 一个轻巧的中国的地区、民族以及节假日信息的查询PHP库
Stars: ✭ 51 (+121.74%)
Mutual labels:  china, regions
world-cities-mongodb
A free world cities database
Stars: ✭ 29 (+26.09%)
Mutual labels:  countries, cities
top-regional-repositories
🌍 The most-relevant repositories for all countries and many cities worldwide.
Stars: ✭ 18 (-21.74%)
Mutual labels:  countries, cities
world
A Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.
Stars: ✭ 479 (+1982.61%)
Mutual labels:  countries, cities
darrrr
An SDK for the delegated recovery specfication
Stars: ✭ 43 (+86.96%)
Mutual labels:  ruby-on-rails
modular routes
Dedicated controllers for each of your Rails route actions.
Stars: ✭ 45 (+95.65%)
Mutual labels:  ruby-on-rails
ramile
China software copyright extraction tool - 中国软件著作权代码自动提取工具
Stars: ✭ 120 (+421.74%)
Mutual labels:  china
souls
SOULs 🔥 Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, RBS/Steep, Active Record, RSpec, RuboCop, and Google Cloud.
Stars: ✭ 327 (+1321.74%)
Mutual labels:  ruby-on-rails
mobility-actiontext
Translate Rails Action Text rich text with Mobility.
Stars: ✭ 27 (+17.39%)
Mutual labels:  ruby-on-rails
new ckeditor
Ruby on Rails + CKEditor 5
Stars: ✭ 27 (+17.39%)
Mutual labels:  ruby-on-rails
CXProvincesMapView
一个基于PaintCode绘制的中国省份地图框架
Stars: ✭ 49 (+113.04%)
Mutual labels:  china
preact-rpc
React Pre-Rendering via RPC
Stars: ✭ 28 (+21.74%)
Mutual labels:  ruby-on-rails
rubocop-linter-action
Rubocop Linter Action: A GitHub Action to run Rubocop against your code!
Stars: ✭ 86 (+273.91%)
Mutual labels:  ruby-on-rails
agenda-saude
Sistema de agendamento de saúde, em uso para gerir filas de vacinação do COVID-19 e H1N1.
Stars: ✭ 119 (+417.39%)
Mutual labels:  ruby-on-rails
sidekiq-sequence
Sequential Sidekiq jobs for Rails
Stars: ✭ 38 (+65.22%)
Mutual labels:  ruby-on-rails
awesome-rails-security
A curated list of security resources for a Ruby on Rails application
Stars: ✭ 36 (+56.52%)
Mutual labels:  ruby-on-rails

ChinaRegions

Gem Version Build Status Coverage Status

ChinaRegions provides Ruby on Rails code for provinces, cities, and districts [prefecture-level cities] in China. The code need to requires Ruby (> 1.9.x) and Rails (> 4.0).

Data Sources

How to update data

If you are using ChinaRegions version 0.1.x be sure to run:

rails g china_regions:regions

to have the javascript file copied over into your project.

Installation

Add it to your Gemfile:

gem 'china_regions'

Run the following command to install it:

bundle install

Run the generator:

rails g china_regions:install

Then you can see the changes that happened to the console:

  • Copy db/migrate/xxxxxxxxxxx_create_china_regions_tables.rb to db/migrate folder.
  • Copy regions.en.yml and regions.zh.yml files to config/locales folders

Create tables (provinces, cities, districts):

rake db:migrate

Copy Models [Province, City, District] into your project:

rails g china_regions:regions

Newly added models:

  • create app/models/province.rb
  • create app/models/city.rb
  • create app/models/district.rb

Download and import the latest regions to your project:

rake china_regions:all

OR

rake china_regions:download
rake china_regions:import
  • Downloading regions from Administrative-divisions-of-China to db/regions folder.
    • db/regions/pca-code.json
  • Import the regions into provinces and cities, districts

Usage

Example:

= form_for @article do |f|

  = f.region_select [:province, :city, :district]

  # form_tag
  = region_select :article, :province_id
  = region_select :article, :city_id
  = region_select :article, :district_id

  OR

  = region_select :article, :province
  = region_select :article, :city
  = region_select :article, :district

  = f.submit class: 'btn'

Add prefix name:

= form_for @article do |f|

  = f.region_select [:province, :city, :district], :prefix => "home"
  = f.region_select [:province, :city, :district], :prefix => "work"

Pre-selected province:

= form_for @article do |f|
  = f.region_select [:province, :city, :district], province: "chongqing"

  OR

  = f.region_select [:province, :city, :district], province: "重庆市"

Prior choice:

= form_for @article do |f|
  = f.region_select [:province, :city, :district],
          priority: {
            province: ["重庆市"],
            district: %w(巴南区 北碚区 渝北区)
          }

Other languages

Contributing

We have a list of valued contributors. Check them all at: https://github.com/encoreshao/china_regions/graphs/contributors

License

Copyright © 2020-02 Encore Shao. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].