mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Apply couple simple tweaks to seeds.rb
This commit is contained in:
10
db/seeds.rb
10
db/seeds.rb
@@ -1,8 +1,6 @@
|
||||
# This file should contain all the record creation needed to seed the database with its default values.
|
||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
||||
#
|
||||
require 'yaml'
|
||||
require 'csv'
|
||||
|
||||
# -- Spree
|
||||
unless Spree::Country.find_by_iso(ENV['DEFAULT_COUNTRY_CODE'])
|
||||
@@ -13,6 +11,7 @@ end
|
||||
|
||||
country = Spree::Country.find_by_iso(ENV['DEFAULT_COUNTRY_CODE'])
|
||||
puts "Country is #{country.to_s}"
|
||||
|
||||
puts "[db:seed] loading states yaml"
|
||||
states = YAML::load_file "db/default/spree/states.yml"
|
||||
puts "States: #{states.to_s}"
|
||||
@@ -22,8 +21,11 @@ puts "[db:seed] Seeding states for " + country.name
|
||||
|
||||
states.each do |state|
|
||||
puts "State: " + state.to_s
|
||||
|
||||
unless Spree::State.find_by_name(state['name'])
|
||||
Spree::State.create!({"name"=>state['name'], "abbr"=>state['abbr'], :country=>country}, without_protection: true)
|
||||
Spree::State.create!(
|
||||
{ name: state['name'], abbr: state['abbr'], country: country },
|
||||
without_protection: true
|
||||
)
|
||||
end
|
||||
puts "set id"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user