china_region_fu 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,11 @@ module ChinaRegionFu
5
5
  if params_valid?(params) and parent_klass = params[:parent_klass].classify.safe_constantize.find(params[:parent_id])
6
6
  table_name = params[:klass].tableize
7
7
  regions = parent_klass.__send__(table_name).select("#{table_name}.id, #{table_name}.name")
8
+ if has_level_column?(params[:klass])
9
+ regions = regions.order('level ASC')
10
+ else
11
+ regions = regions.order('name ASC')
12
+ end
8
13
  self.response_body = regions.to_json
9
14
  else
10
15
  self.response_body = [].to_json
@@ -14,6 +19,10 @@ module ChinaRegionFu
14
19
 
15
20
  private
16
21
 
22
+ def has_level_column?(klass_name)
23
+ klass_name.classify.safe_constantize.try(:column_names).to_a.include?('level')
24
+ end
25
+
17
26
  def params_valid?(params)
18
27
  params[:klass].present? and params[:parent_klass] =~ /^province|city$/i and params[:parent_id].present?
19
28
  end
@@ -1,8 +1,6 @@
1
1
  require "china_region_fu/version"
2
2
  require 'china_region_fu/engine' if defined? Rails
3
3
 
4
- module ChinaRegionFu
5
- YAML_FILE = File.expand_path('../../config/regions.yml', __FILE__)
6
- end
4
+ module ChinaRegionFu;end
7
5
 
8
6
  require 'china_region_fu/helper'
@@ -1,3 +1,3 @@
1
1
  module ChinaRegionFu
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -7478,6 +7478,12 @@
7478
7478
  中沙群岛的岛礁及其海域:
7479
7479
  pinyin: zhongshaqundaodedaojiaojiqihaiyu
7480
7480
  pinyin_abbr: zsqdddjjqhy
7481
+ 三沙市:
7482
+ pinyin: sansha
7483
+ pinyin_abbr: ss
7484
+ zip_code: '000000'
7485
+ level: 4
7486
+ districts: {}
7481
7487
  重庆市:
7482
7488
  pinyin: chongqing
7483
7489
  pinyin_abbr: cq
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: china_region_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-19 00:00:00.000000000 Z
12
+ date: 2012-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jquery-rails