china_regions 0.0.4 → 0.0.5
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.
- data/README.md +12 -12
- data/app/models/district.rb +4 -1
- data/config/locales/en.yml +1 -1
- data/lib/china_regions/helpers/form_helper.rb +1 -1
- data/lib/china_regions/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -43,22 +43,22 @@ bundle install
|
|
43
43
|
|
44
44
|
范例:
|
45
45
|
|
46
|
-
= form_for @article do |f|
|
46
|
+
= form_for @article do |f|
|
47
47
|
|
48
|
-
|
48
|
+
= f.region_select [:province, :city, :district]
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
# form_tag
|
51
|
+
= region_select :article, :province_id
|
52
|
+
= region_select :article, :city_id
|
53
|
+
= region_select :article, :district_id
|
54
54
|
|
55
|
-
|
55
|
+
OR
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
= region_select :article, :province
|
58
|
+
= region_select :article, :city
|
59
|
+
= region_select :article, :district
|
60
|
+
|
61
|
+
= f.submit class: 'btn'
|
62
62
|
|
63
63
|
|
64
64
|
## Contributing
|
data/app/models/district.rb
CHANGED
@@ -5,10 +5,13 @@ class District < ActiveRecord::Base
|
|
5
5
|
attr_accessible :name, :city_id, :name_en, :name_abbr
|
6
6
|
|
7
7
|
belongs_to :city
|
8
|
-
belongs_to :province
|
9
8
|
|
10
9
|
scope :with_city, ->(city) { where(city_id: city) }
|
11
10
|
|
11
|
+
def province
|
12
|
+
city.province
|
13
|
+
end
|
14
|
+
|
12
15
|
def short_name
|
13
16
|
@short_name ||= name.gsub(/区|县|市|自治县/, '')
|
14
17
|
end
|
data/config/locales/en.yml
CHANGED