-
-
Save marcocarvalho/6569861 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
states = <<STATES | |
AC,Acre | |
AL,Alagoas | |
AP,Amapá | |
AM,Amazonas | |
BA,Bahia | |
CE,Ceará | |
ES,Espírito Santo | |
GO,Goiás | |
MA,Maranhão | |
MT,Mato Grosso | |
MS,Mato Grosso do Sul | |
MG,Minas Gerais | |
PA,Pará | |
PB,Paraíba | |
PR,Paraná | |
PE,Pernambuco | |
PI,Piauí | |
RJ,Rio de Janeiro | |
RN,Rio Grande do Norte | |
RS,Rio Grande do Sul | |
RO,Rondônia | |
RR,Roraima | |
SC,Santa Catarina | |
SP,São Paulo | |
SE,Sergipe | |
TO,Tocantins | |
DF,Distrito Federal | |
STATES | |
country = Spree::Country.where(iso_name: 'BRAZIL').first | |
country.name = 'Brasil' | |
country.save | |
Spree::State.transaction do | |
states.split("\n").each do |state| | |
values = state.split ',' | |
next if values.first.blank? or values.last.blank? | |
Spree::State.create! :country_id => country.id, :abbr => values[0], :name => values[1] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment