From f9e86bed27e6ba15d22d0bbe4bf6aa16b4ce7460 Mon Sep 17 00:00:00 2001 From: songtianlun Date: Wed, 26 Feb 2025 14:43:34 +0800 Subject: [PATCH] fix: update city attributes assignment --- lib/tasks/sync_geo_data.rake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/tasks/sync_geo_data.rake b/lib/tasks/sync_geo_data.rake index 60283c3..d2a6f2d 100644 --- a/lib/tasks/sync_geo_data.rake +++ b/lib/tasks/sync_geo_data.rake @@ -173,14 +173,15 @@ namespace :geo do # 使用多个属性来确保唯一性 city = City.find_or_initialize_by( name: data["name"], - latitude: data["latitude"], - longitude: data["longitude"], - country_id: country.id + country_id: country.id, + state_id: state.id ) # 更新或设置城市属性 city.assign_attributes( country_code: country.code, + latitude: data["latitude"], + longitude: data["longitude"], state_id: state&.id, state_code: state&.code, flag: data["flag"] || true,