Sha256: e019221cc9edb7b9d3607eaca376f098e2be707d26f95b38ff2abbc1e561d3b7

Contents?: true

Size: 532 Bytes

Versions: 88

Compression:

Stored size: 532 Bytes

Contents

require "countries"

class PopulateCountriesAndStates < ActiveRecord::Migration
  def change
    ISO3166::Country.all.each do |country_array|
      name = country_array[0]
      abbr = country_array[1]
      country = Piggybak::Country.create :name => name, :abbr => abbr

      iso3166_country = ISO3166::Country.new(abbr)
      iso3166_country.states.each do |key, value|
        abbr = key
        name = value["name"]
        Piggybak::State.create! :name => name, :abbr => abbr, :country => country
      end
    end
  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
piggybak-0.6.34 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.7.1 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.7.0 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.33 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.32 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.31 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.30 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.29 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.28 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.27 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.26 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.25 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.24 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.23 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.22 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.21 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.20 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.19 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.18 db/migrate/20120104020930_populate_countries_and_states.rb
piggybak-0.6.17 db/migrate/20120104020930_populate_countries_and_states.rb