1
0
Fork 0

Improve "db/seeds.rb"

This commit is contained in:
Alex Kotov 2019-04-27 17:40:12 +05:00
parent 09c86d53a8
commit 393c0af25c
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
1 changed files with 4 additions and 3 deletions

View File

@ -9,9 +9,10 @@ CSV.foreach country_states_filename,
native_name.strip!
english_name.strip!
next if CountryState.where(english_name: english_name).exists?
CountryState.create! english_name: english_name, native_name: native_name
CountryState.where(english_name: english_name)
.first_or_create! do |new_country_state|
new_country_state.native_name = native_name
end
end
Rails.application.settings(:superuser).tap do |config|