diff --git a/lib/tasks/sync_geo_data.rake b/lib/tasks/sync_geo_data.rake index 2e4490f..cb602f4 100644 --- a/lib/tasks/sync_geo_data.rake +++ b/lib/tasks/sync_geo_data.rake @@ -84,8 +84,9 @@ namespace :geo do count += 1 # 查找或初始化 Country - country = Country.find_or_create_by(code: data["iso2"]) do |c| - c.name = data["name"] + country = Country.find_by(code: data["iso2"]) + if country.nil? + country = Country.new end # 更新 Country 属性