Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Episode3: Watchman -- Datastores in YML and Postgres
Episode3: Watchman -- Datastores in YML and Postgres
====================================================

Storing data in Postgres, with migrations, outside of Rails
Expand Down
6 changes: 0 additions & 6 deletions config/database.yml.sample

This file was deleted.

13 changes: 0 additions & 13 deletions db/migrate/201205031300_create_networks.rb

This file was deleted.

17 changes: 15 additions & 2 deletions db/seed.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# Cleaning Out

Network.delete_all
Show.delete_all
Coffee.delete_all

amc = Network.create(name: "AMC")
nbc = Network.create(name: "NBC")
netflix = Network.create(name: "Netflix")
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: "Community", day_of_week: "Thursday", hour_of_day: 19, network: nbc)
Show.create(name: "House of Cards", day_of_week: "Thursday", hour_of_day: 0, network: netflix)
Show.create(name: "Orange is the New Black", day_of_week: "Sunday" , hour_of_day: 0, network: netflix)

Coffee.create(name: 'Costa Rica', grade: 'SHB EP', process: 'Washed', region: 'Santa Maria de Dota', roast: 'Full City')
Coffee.create(name: 'Guatemala', grade: 'SHB', process: 'Washed', region: 'San Pedro Necta', roast: 'City')
Coffee.create(name: 'Honduras', grade: 'SHB', process: 'Washed', region: 'Ocotopeque', roast: 'City - Full City')
Coffee.create(name: 'Bolivia', grade: 'n/a', process: 'n/a', region: 'Caranavi', roast: 'Just brew')
Coffee.create(name: 'Java', grade: 'One', process: 'Washed', region: 'Java Sunda', roast: 'Full City')


5 changes: 3 additions & 2 deletions models/show.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
class Show < ActiveRecord::Base
belongs_to :network

validates_presence_of :name
validates_presence_of :name

def to_s
"#{name} airs at #{hour_of_day}:#{day_of_week}:00 on #{network} "
end
end


Empty file removed spec/.gitkeep
Empty file.
26 changes: 24 additions & 2 deletions watchman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,29 @@

Network.all.each do |network|
puts "Shows airing on #{network}"
network.shows.each do |show|
network.shows.each do |show| #this is really cool
puts show
end
end
end
puts "------------------------"

puts "Which day do you want to watch the show?"
day = gets.chomp.capitalize
puts "Shows airing on #{day}"

Show.all.to_a.select{|show| show.day_of_week == day}.each do |show|
puts show
end

puts "-------------------------"

Coffee.all.each do |coffee|
puts coffee.name
end

puts "Which coffee do you want to know more about?"
cof = gets.chomp.capitalize
Coffee.all.to_a.select{|coffee| coffee == cof}.each do |coffee|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

puts coffee

end