-
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
eagle-, tiger-, + panda-level tasks #15
Open
ellesuzuki
wants to merge
3
commits into
RubyoffRails:master
Choose a base branch
from
ellesuzuki:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateProjects < ActiveRecord::Migration | ||
def change | ||
create_table :projects do |t| | ||
t.string :name | ||
t.string :category | ||
t.string :recipient | ||
t.timestamps | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateYarns < ActiveRecord::Migration | ||
create_table :yarns do |t| | ||
t.string :material | ||
t.string :weight | ||
t.timestamps | ||
end | ||
|
||
change_table :projects do |t| | ||
t.references :yarn | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateNeedles < ActiveRecord::Migration | ||
create_table :needles do |t| | ||
t.string :category | ||
t.string :size | ||
t.timestamps | ||
end | ||
|
||
change_table :projects do |t| | ||
t.references :needle | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
# Cleaning Out | ||
Network.delete_all | ||
Show.delete_all | ||
Needle.delete_all | ||
Yarn.delete_all | ||
Project.delete_all | ||
|
||
# set up | ||
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: 'Elementary', day_of_week: 'Thursday', hour_of_day: 22, network: cbs) | ||
Show.create(name: 'Person of Interest', day_of_week: 'Thursday', hour_of_day: 21, network: cbs) | ||
|
||
dpns3 = Needle.create(category: 'dpns', size: 3) | ||
dpns2 = Needle.create(category: 'dpns', size: 2) | ||
str8 = Needle.create(category: 'straights', size: 8) | ||
|
||
wool_worsted = Yarn.create(material: 'merino wool', weight: 'worsted') | ||
acrylic_sock = Yarn.create(material: 'acrylic', weight: 'sock') | ||
|
||
Project.create(name: 'Birthday Present', category: 'socks', needle: dpns3, yarn: acrylic_sock, recipient: 'Yuki') | ||
Project.create(name: 'Bro Graduation Present', category: 'hat', needle: str8, yarn: wool_worsted, recipient: 'Patrick') | ||
Project.create(name: 'Bro New Year Present', category: 'scarf', needle: str8, yarn: wool_worsted, recipient: 'Chris') | ||
Project.create(name: 'Practice Project', category: 'socks', needle: dpns2, yarn: acrylic_sock, recipient: 'self') | ||
Project.create(name: 'Just Because', category: 'scarf', needle: str8, yarn: wool_worsted, recipient: 'Darryl') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Needle < ActiveRecord::Base | ||
has_many :projects | ||
|
||
def to_s | ||
"#{size} #{category}" | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Project < ActiveRecord::Base | ||
validates_presence_of :name | ||
|
||
belongs_to :yarn | ||
belongs_to :needle | ||
|
||
def to_s | ||
"\"#{name}\", [#{category}, #{recipient}, #{needle}, #{yarn}]" | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Yarn < ActiveRecord::Base | ||
has_many :projects | ||
|
||
def to_s | ||
"#{weight} #{material}" | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,56 @@ | |
|
||
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 | ||
# output by network | ||
#Network.all.each do |network| | ||
# puts "Shows airing on #{network}" | ||
# network.shows.each do |show| | ||
# puts show | ||
# end | ||
#end | ||
|
||
# output all shows | ||
Show.all.each do |show| | ||
puts show | ||
end | ||
|
||
puts | ||
puts "What day are you interested in? (eg, Friday)" | ||
answer = gets.chomp | ||
|
||
shows = [] | ||
Show.all.each do |show| | ||
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. Here you should use the ActiveRecord query interface...
|
||
if show.day_of_week == answer | ||
shows << show | ||
end | ||
end | ||
|
||
if shows.size != 0 | ||
shows.each do |s| | ||
puts "#{s.name} at #{s.hour_of_day} on #{s.network}" | ||
end | ||
else | ||
puts 'No shows found.' | ||
end | ||
|
||
# output all my knitting projects | ||
puts | ||
puts "My current knitting projects: " | ||
Project.all.each do |project| | ||
puts project | ||
end | ||
|
||
puts | ||
puts "Which project would you like to see details for?" | ||
answer = gets.chomp | ||
|
||
counter = 0 | ||
Project.all.each do |proj| | ||
if proj.name == answer | ||
counter += 1 | ||
puts proj | ||
break | ||
end | ||
end | ||
|
||
puts 'Sorry, project not found.' if counter == 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
(I'd rather just delete commented code)