-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
just panda #24
base: master
Are you sure you want to change the base?
just panda #24
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
# Cleaning Out | ||
|
||
Network.delete_all | ||
Show.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) | ||
|
||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ class Network < ActiveRecord::Base | |
|
||
def to_s | ||
name | ||
end | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
class Show < ActiveRecord::Base | ||
belongs_to :network | ||
class Show < ActiveRecord::Base | ||
belongs_to :network | ||
|
||
validates_presence_of :name | ||
#validates_presence_of :name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like code that is commented... I recommend removing it, since you can always go back in time via git. |
||
def to_s | ||
"#{name}, #{day_of_week}, #{hour_of_day}, #{network}" | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that formatting local to your culture? Or, did "day_of_week" sneek in there instead of minute? |
||
|
||
def to_s | ||
"#{name} airs at #{hour_of_day}:#{day_of_week}:00 on #{network} " | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,32 @@ | |
require "./db/setup" | ||
Dir.glob('./models/*').each { |r| require r} | ||
require "./db/seed" | ||
require "./db/seeds" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't figure this one out --- the |
||
|
||
|
||
puts "There are #{Show.count} in the database" | ||
|
||
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 "------------------------" | ||
Show.all.each do |show| | ||
puts show | ||
end | ||
puts "------------------------" | ||
puts "Which day do you want to watch the show?" | ||
day = gets.chomp().capitalize | ||
puts "Shows airing on #{day}" | ||
Show.all.each do |show| | ||
puts show if show.day_of_week == day | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works well... I also like this method, where we limit the things we are looping before we loop over them Show.all.to_a.select{|show| show.day_of_week == day}.each do |show|
puts show
end So the |
||
end | ||
|
||
puts "-------------------------" | ||
|
||
|
||
Food.all.each do |food| | ||
puts food | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on the shows, BTW. I ❤️ them 😃