fix: improve country creation logic
- Refactor the country creation process to use a block for setting the name attribute. - Ensure that the name is set explicitly when a new country is created with the appropriate ISO code. This change optimizes the way country records are created and ensures the name is always correctly assigned during the creation process.
This commit is contained in:
parent
d3dae4f079
commit
f67ff92ba8
@ -82,7 +82,9 @@ namespace :geo do
|
||||
count += 1
|
||||
|
||||
# 查找或初始化 Country
|
||||
country = Country.find_or_create_by!(code: data["iso2"], name: data["name"])
|
||||
country = Country.find_or_create_by!(code: data["iso2"]) do |c|
|
||||
c.name = data["name"]
|
||||
end
|
||||
|
||||
# 更新 Country 属性
|
||||
country.update!(
|
||||
|
Loading…
Reference in New Issue
Block a user