Skip to content

Instantly share code, notes, and snippets.

@marcocarvalho
Forked from dcrec1/seeds.rb
Last active December 23, 2015 02:49
Show Gist options
  • Save marcocarvalho/6569861 to your computer and use it in GitHub Desktop.
Save marcocarvalho/6569861 to your computer and use it in GitHub Desktop.
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