Skip to content

Instantly share code, notes, and snippets.

@shingonoide
Forked from dcrec1/seeds.rb
Created April 6, 2011 12:04
Show Gist options
  • Save shingonoide/905539 to your computer and use it in GitHub Desktop.
Save shingonoide/905539 to your computer and use it in GitHub Desktop.
# 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