parsley/db/seeds.rb

41 lines
2.0 KiB
Ruby
Raw Normal View History

2016-01-12 18:43:00 -06:00
# 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).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
2016-01-14 15:22:15 -06:00
2016-01-24 17:10:43 -06:00
require 'usda_importer'
2016-01-14 15:22:15 -06:00
puts "Seeding..."
Ingredient.create!([
2016-01-14 18:56:45 -06:00
{name: 'Water', density: '1 g/ml'},
2016-01-24 17:10:43 -06:00
{name: 'Butter, Salted', density: '226 gram/cup', ndbn: '01001'},
2016-01-14 15:22:15 -06:00
{name: 'Butter, Unsalted', density: '226 gram/cup'},
{name: 'Flour, Bleached All Purpose', density: '130 gram/cup'},
{name: 'Flour, Cake', density: '120 gram/cup'},
{name: 'Flour, Whole Wheat', density: '130 gram/cup'},
{name: 'Cornstarch', density: '10 gram/tablespoon'},
{name: 'Cornmeal', density: '120 gram/cup'},
{name: 'Sugar, Granulated', density: '200 gram/cup'},
{name: 'Sugar, Brown, Lightly Packed', density: '210 gram/cup'},
{name: 'Sugar, Powdered', density: '120 gram/cup'},
{name: 'Chocolate Chips', density: '170 gram/cup'},
2016-01-18 20:50:19 -06:00
{name: 'Cocoa Powder', density: '100 gram/cup'},
{name: 'Salt, Kosher', density: '248 gram/cup'},
{name: 'Salt, Table', density: '304 gram/cup'},
{name: 'Milk, Whole', density: '1.028 gram/ml'},
{name: 'Milk, Skim', density: '1.032 gram/ml'},
{name: 'Milk, 2%', density: '1.03 gram/ml'}
2016-01-14 15:22:15 -06:00
])
2016-01-28 14:19:51 -06:00
User.create!({username: 'dan', full_name: 'Dan', email: 'dan.elbert@gmail.com', password: 'qwerty', password_confirmation: 'qwerty'})
2016-01-24 17:10:43 -06:00
importer = UsdaImporter.new(Rails.root.join('vendor', 'data', 'usda', 'ABBREV.txt'))
importer.import
2016-01-14 15:22:15 -06:00
2016-01-28 14:19:51 -06:00
puts "Seeds planted."