Created
September 12, 2012 23:34
-
-
Save chyld/3710772 to your computer and use it in GitHub Desktop.
seed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
g1 = Grocery.create(:name => "milk", :quantity => 3) | |
g2 = Grocery.create(:name => "eggs", :quantity => 12) | |
g3 = Grocery.create(:name => "bread", :quantity => 2) | |
k = Kitchen.create(:name => "chyld's kitchen") | |
r1 = Recipe.create(:name => "pancakes", :rating => 3) | |
r2 = Recipe.create(:name => "biscuits", :rating => 5) | |
r3 = Recipe.create(:name => "ice cream", :rating => 2) | |
k.groceries = [g1,g2,g3] | |
k.recipes = [r1,r2,r3] | |
item1 = Item.create(:quantity => 5) | |
item2 = Item.create(:quantity => 2) | |
item3 = Item.create(:quantity => 7) | |
in1 = Ingredient.create(:name => "flour", :unit => "cups") | |
in2 = Ingredient.create(:name => "sugar", :unit => "grams") | |
in3 = Ingredient.create(:name => "honey", :unit => "ml") | |
item1.ingredient = in1 | |
item2.ingredient = in2 | |
item3.ingredient = in3 | |
item1.save | |
item2.save | |
item3.save | |
r1.items = [item1, item2, item3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment