diff --git a/db/migrate/201401161200_create_reviews.rb b/db/migrate/201401161200_create_reviews.rb new file mode 100644 index 0000000..a780a44 --- /dev/null +++ b/db/migrate/201401161200_create_reviews.rb @@ -0,0 +1,10 @@ +class CreateReviews < ActiveRecord::Migration + def change + create_table :reviews do |t| + t.string :movie + t.integer :rating + t.string :reviewer + t.string :synopsis + end + end +end \ No newline at end of file diff --git a/db/seed.rb b/db/seed.rb index 3c028ff..2283d22 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -1,7 +1,32 @@ # Cleaning Out Network.delete_all Show.delete_all -amc = Network.create(name: "AMC") -nbc = Network.create(name: "NBC") +Review.delete_all +amc = Network.create(name: "AMC") +nbc = Network.create(name: "NBC") +bravo = Network.create(name: "Bravo") 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: "Top Chef", day_of_week: "Wednesday", hour_of_day: 19, network: bravo) +Show.create(name: "Walking Dead", day_of_week: "Sunday", hour_of_day: 20, network: amc) + +Review.create(movie: "Pulp Fiction", + rating: 5, + reviewer: "Anthony Lane", + synopsis: "The talk is dirty and funny, the violence always waiting just around the corner.") +Review.create(movie: "Raiders of the Lost Ark", + rating: 5, + reviewer: "Gene Siskel", + synopsis: "Yes, it's as entertaining as you have heard. Maybe more so. Raiders of the Lost Ark is, in fact, about as entertaining as a commercial movie can be.") +Review.create(movie: "Amadeus", + rating: 5, + reviewer: "Gene Siskel", + synopsis: "The subject of artistic creation is typically handled badly in the movies.... [Amadeus] treats the subject of creativity in a fresh way.") +Review.create(movie: "American Hustle", + rating: 5, + reviewer: "Joe Neumaier", + synopsis: "It turns out that comb-overs, cleavage, cocaine and kookiness are an unbeatable combo.") +Review.create(movie: "The Big Lebowski", + rating: 5, + reviewer: "Rick Groen", + synopsis: "A typical Coen brothers film is like no film you've ever seen.") diff --git a/models/review.rb b/models/review.rb new file mode 100644 index 0000000..3c43de9 --- /dev/null +++ b/models/review.rb @@ -0,0 +1,5 @@ +class Review < ActiveRecord::Base + def to_s + "#{movie}, Reviewed by: #{reviewer}, Rating: #{rating}, Review: #{synopsis}" + end +end \ No newline at end of file diff --git a/models/show.rb b/models/show.rb index 6c82f65..9742c64 100644 --- a/models/show.rb +++ b/models/show.rb @@ -4,6 +4,6 @@ class Show < ActiveRecord::Base validates_presence_of :name def to_s - "#{name} airs at #{hour_of_day}:#{day_of_week}:00 on #{network} " + "#{name} airs at #{day_of_week}, #{hour_of_day}:00 on #{network}." end end diff --git a/watchman.rb b/watchman.rb index ebe9be4..c9cd90b 100644 --- a/watchman.rb +++ b/watchman.rb @@ -5,11 +5,19 @@ Dir.glob('./models/*').each { |r| require r} require "./db/seed" -puts "There are #{Show.count} in the database" - -Network.all.each do |network| - puts "Shows airing on #{network}" - network.shows.each do |show| - puts show - end +puts "***********************" +puts "* Welcome to WATCHMAN *" +puts "***********************" +puts "There are #{Review.count} reviews in the database:" +puts "" +Review.all.each do |review| + puts review.movie end +puts "What movie review would you like to see?" +print "> " + +movie_selection = gets.chomp + +my_selection = Review.where(movie: movie_selection) +puts "Oops... we don't have a review for #{movie_selection} yet." if my_selection.empty? +my_selection.each { |review| puts review } \ No newline at end of file