Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
State of Brazil for Spree
states = <<STATES
28,AC,Acre
28,AL,Alagoas
28,AP,Amapá
28,AM,Amazonas
28,BA,Bahia
28,CE,Ceará
28,ES,Espírito Santo
28,GO,Goiás
28,MA,Maranhão
28,MT,Mato Grosso
28,MS,Mato Grosso do Sul
28,MG,Minas Gerais
28,PA,Pará
28,PB,Paraíba
28,PR,Paraná
28,PE,Pernambuco
28,PI,Piauí
28,RJ,Rio de Janeiro
28,RN,Rio Grande do Norte
28,RS,Rio Grande do Sul
28,RO,Rondônia
28,RR,Roraima
28,SC,Santa Catarina
28,SP,São Paulo
28,SE,Sergipe
28,TO,Tocantins
28,DF,Distrito Federal
STATES
State.transaction do
states.each do |state|
values = state.split ','
State.create! :country_id => values[0], :abbr => values[1], :name => values[2].sub("\n", "")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment