Skip to content

Instantly share code, notes, and snippets.

@jbourassa
Created June 13, 2012 18:37
Show Gist options
  • Save jbourassa/2925711 to your computer and use it in GitHub Desktop.
Save jbourassa/2925711 to your computer and use it in GitHub Desktop.
Add provinces to Spree
# encoding: utf-8
canada = Spree::Country.find_by_iso('CA')
Spree::State.delete_all country_id: canada.id
provinces = [
{ name: "Québec", abbr: "QC" },
{ name: "Ontario", abbr: "ON" },
{ name: "British Columbia", abbr: "BC" },
{ name: "Alberta", abbr: "AB" },
{ name: "Manitoba", abbr: "MB" },
{ name: "Saskatchewan", abbr: "SK" },
{ name: "Nova Scotia", abbr: "NS" },
{ name: "New Brunswick", abbr: "NB" },
{ name: "Newfoundland and Labrador", abbr: "NL" },
{ name: "Prince Edward Island", abbr: "PE" },
{ name: "Northwest Territories", abbr: "NT" },
{ name: "Yukon", abbr: "YT" },
{ name: "Nunavut", abbr: "NY" },
]
provinces.each do |province|
state = Spree::State.new province
state.country = canada
state.save!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment