-
-
Save shingonoide/905539 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# encoding: UTF-8 | |
namespace :brazil do | |
desc "Load brazilian states for spree store" | |
task :states => :environment do | |
brazil = Country.find :first, :conditions => {:name => "Brazil"} | |
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 | |
State.transaction do | |
states.each_line do |state| | |
values = state.split ',' | |
State.create! :country => brazil, :abbr => values[0], :name => values[1].sub("\n", "") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment