Octos, Jamila#36
Open
Jcornick21 wants to merge 6 commits into
Open
Conversation
Grocery StoreWhat We're Looking For
|
CheezItMan
reviewed
Feb 23, 2018
| require "pry" | ||
|
|
||
| # access CSV and other type use require relative | ||
| FILE_NAME = "../support/orders.csv" |
There was a problem hiding this comment.
- Good that you're using a constant!
- The path is off. You should write it from the perspective of whomever is running the app. Users should run
rakefrom the project's home folder, so the path to the CSV from the home folder issupport/orders.csv
So this should be:
FILENAME = "support/orders.csv"| @products[product_name]= product_price | ||
| return true | ||
| end | ||
| return products |
| end | ||
|
|
||
| def self.all | ||
| all_orders = [] |
There was a problem hiding this comment.
This method is a little overly complicated.
CSV.open.each will loop through each row, and below where you have all_orders.each will also loop through each row. So you could merge the two, eliminating the CSV.open loop and replace the top line of the 2nd with:
CSV.open(FILE_NAME, 'r').each do |order|
However what' you've got works and that's good.
| end | ||
|
|
||
| def self.find(id) | ||
| Grocery::Order.all.each do |order| |
There was a problem hiding this comment.
This isn't working. It's good that you're using Order.all to get the list, but instead of returning order.products it should just return order
If the loop finishes without finding an order it should return nil
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Grocery Store
Congratulations! You're submitting your assignment.
Comprehension Questions
raise ArgumentError?.all&.findmethods class methods? Why not instance methods?