Files
openfoodnetwork/db/seeds.rb
2014-07-17 14:26:46 +10:00

33 lines
1.0 KiB
Ruby

# 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).
# -- Spree
unless Spree::Country.find_by_name 'Australia'
puts "[db:seed] Seeding Spree"
Spree::Core::Engine.load_seed if defined?(Spree::Core)
Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
end
# -- States
unless Spree::State.find_by_name 'Victoria'
country = Spree::Country.find_by_name('Australia')
puts "[db:seed] Seeding states"
[
['ACT', 'ACT'],
['New South Wales', 'NSW'],
['Northern Territory', 'NT'],
['Queensland', 'QLD'],
['South Australia', 'SA'],
['Tasmania', 'Tas'],
['Victoria', 'Vic'],
['Western Australia', 'WA']
].each do |state|
Spree::State.create!({"name"=>state[0], "abbr"=>state[1], :country=>country}, :without_protection => true)
end
end
# -- Suburbs
require_relative './suburb_seeds'
SuburbSeeder.seed_suburbs unless Suburb.find_by_name("Dayton")