geonames_rails 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,6 +41,7 @@ class CreateGeonamesTables < ActiveRecord::Migration
41
41
  # create cities
42
42
  create_table :cities do |t|
43
43
  t.integer :country_id, :null => false
44
+ t.integer :division_id
44
45
  # [0] geonameid : integer id of record in geonames database
45
46
  t.integer :geonames_id, :null => false
46
47
  # [1] name : name of geographical point (utf8) varchar(200)
@@ -1,3 +1,4 @@
1
1
  class City < ActiveRecord::Base
2
2
  belongs_to :country
3
+ belongs_to :division
3
4
  end
@@ -1,3 +1,4 @@
1
1
  class Division < ActiveRecord::Base
2
2
  belongs_to :country
3
+ has_many :cities
3
4
  end
@@ -18,8 +18,8 @@ module GeonamesRails
18
18
  @puller.pull if @puller # pull geonames files down
19
19
 
20
20
  load_countries
21
- load_cities
22
21
  load_divisions
22
+ load_cities
23
23
 
24
24
  @puller.cleanup if @puller # cleanup the geonames files
25
25
  end
@@ -64,6 +64,9 @@ module GeonamesRails
64
64
  :admin_2_code,
65
65
  :admin_3_code,
66
66
  :admin_4_code)
67
+
68
+ division = Division.find_by_full_code(city.country_iso_code_two_letters+"."+city.admin_1_code )
69
+ city.division_id = division.id unless division.blank?
67
70
 
68
71
  city.save!
69
72
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marius Andra