diff --git a/db/migrate/201303251230_create_recipes.rb b/db/migrate/201303251230_create_recipes.rb new file mode 100644 index 0000000..81b226c --- /dev/null +++ b/db/migrate/201303251230_create_recipes.rb @@ -0,0 +1,9 @@ +class CreateRecipes < ActiveRecord::Migration + def change + create_table :recipes do |t| + t.string :dish + t.string :ingredients + t.string :instructions + end + end +end diff --git a/db/seed.rb b/db/seed.rb index 3c028ff..5521be7 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -3,5 +3,15 @@ Show.delete_all amc = Network.create(name: "AMC") nbc = Network.create(name: "NBC") +cbs = Network.create(name: "CBS") Show.create(name: "Mad Men", day_of_week: "Sunday", hour_of_day: 22, network: amc) Show.create(name: "Community", day_of_week: "Thursday", hour_of_day: 20, network: nbc) +Show.create(name: "60 Minutes", day_of_week: "Sunday", hour_of_day: 18, network: cbs) +Show.create(name: "Survivor", day_of_week: "Thursday", hour_of_day: 20, network: cbs) + +Recipe.delete_all +Recipe.create(dish: "salsa", ingredients: "[tomatoes, jalapenos, cilantro, onions]", instructions: "chop and mix all ingredients together; season to taste") +Recipe.create(dish: "guacamole", ingredients: "[avocados, tomatoes, jalapeno, cilantro, onions, cumin]", instructions: "mash avocados; dice onions and tomatoes; mix all ingredients together; season to taste") +Recipe.create(dish: "lentil soup", ingredients: "[red lentils, onions, celery, tomatoes, herbs de provence]", instructions: "saute diced onions and celery in olive oil for 5 min; add red lentils, water, tomatoes, and spices; cook for 20 minutes") +Recipe.create(dish: "bruschetta", ingredients: "[bread, tomatoes, basil, red onions, basalmic vinegar]", instructions: "chop tomatoes, basil, red onions; add basalmic vinegar to mixture; serve with toasted bread") +Recipe.create(dish: "hummus", ingredients: "[chickpeas, tahini, garlic, olive oil]", instructions: "put all ingredients in blender and blend until it reaches smooth texture") diff --git a/models/recipe.rb b/models/recipe.rb new file mode 100644 index 0000000..a52882d --- /dev/null +++ b/models/recipe.rb @@ -0,0 +1,8 @@ +class Recipe < ActiveRecord::Base + + validates_presence_of :dish + + def to_s + "#{dish} has the following ingredients #{ingredients} " + end +end diff --git a/watchman.rb b/watchman.rb index ebe9be4..54c395e 100644 --- a/watchman.rb +++ b/watchman.rb @@ -6,10 +6,34 @@ require "./db/seed" puts "There are #{Show.count} in the database" +puts "What day of the week would you like to watch a show?" +day_of_week = gets.chomp +show_in_entered_day_of_week = false Network.all.each do |network| - puts "Shows airing on #{network}" network.shows.each do |show| - puts show - end + if show.day_of_week == day_of_week + puts "#{show} on #{network}" + show_in_entered_day_of_week = true + end + end end +puts "no shows air on #{day_of_week}" unless show_in_entered_day_of_week +puts "\n\n\n\n" + + +puts "These are the all the dishes in the database :" +Recipe.all.each do |recipe| + puts "#{recipe}" +end +puts "What would you like to make?" +dish = gets.chomp +recipe_exists = false +Recipe.all.each do |recipe| + if recipe.dish == dish + puts "This is how you make #{dish} :" + puts "#{recipe.instructions}" + recipe_exists = true + end +end +puts "Sorry, #{dish} does not exist in the database" unless recipe_exists