Skip to content

Commit 3777373

Browse files
committed
fix db:seed
1 parent adc4ac9 commit 3777373

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

db/seeds.rb

+3-8
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@
1111

1212
h = Hash.from_xml(open('https://raw.github.com/ChokePointProject/cpp-web/master/tmp/countryInfo.xml'))['geonames']['country']
1313

14-
# 1st sweep: continents
1514
h.each do |c|
16-
Continent.find_or_create_by_code_and_name(c['continent'], c['continentName'])
17-
end
18-
19-
# 2nd sweep: countries
20-
h.each do |c|
21-
Country.create(
22-
:continent_id => Continent.find_by_code(c['continent']),
15+
n = Country.new(
2316
:code => c['countryCode'],
2417
:name => c['countryName'],
2518
:isoNumeric => c['isoNumeric'],
@@ -36,5 +29,7 @@
3629
:bBoxEast => c['bBoxEast'],
3730
:bBoxSouth => c['bBoxSouth']
3831
)
32+
n.continent = Continent.find_or_create_by_code_and_name(c['continent'], c['continentName'])
33+
n.save!
3934
end
4035

0 commit comments

Comments
 (0)