Conversation
Add customer fields
Video Store APIMajor Learning Goals/Code Review
Functional Requirements
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
|
kaidamasaki
left a comment
There was a problem hiding this comment.
Great job! I left a few comments but honestly don't have too much to say, your solution was really solid. 😃
| class Customer < ApplicationRecord | ||
| has_many :rentals | ||
|
|
||
| validates :id, presence: true |
There was a problem hiding this comment.
Requiring id to be present means that you can't rely on auto-assignment of IDs and breaks db:seed.
This isn't something you'd catch without doing a rails db:reset or something though, just something to keep in mind in the future.
| def update_check_out_dates | ||
| self.check_out_date = Date.today | ||
| self.due_date = Date.today + 7 | ||
| end |
There was a problem hiding this comment.
It's confusing that this method doesn't save but your other update methods do.
| def update_check_out_dates | |
| self.check_out_date = Date.today | |
| self.due_date = Date.today + 7 | |
| end | |
| def update_check_out_dates | |
| self.check_out_date = Date.today | |
| self.due_date = Date.today + 7 | |
| return self.save | |
| end |
| if @video.nil? || @customer.nil? | ||
| render json: { | ||
| errors: ['Not Found'], | ||
| }, status: :not_found | ||
|
|
||
| return | ||
| end |
There was a problem hiding this comment.
Since you repeat this logic I'd probably move it into find_video_and_customer as well.
| let(:customer) { | ||
| customers(:pengsoo) | ||
| } | ||
| let(:video) { | ||
| videos(:parasite) | ||
| } | ||
|
|
||
| let(:rental_data) { | ||
| { | ||
| customer_id: customer.id, | ||
| video_id: video.id | ||
| } | ||
| } |
| } | ||
|
|
||
| before do # important! | ||
| post check_out_path, params: rental_params |
There was a problem hiding this comment.
I would probably have directly created the Rental instead of posting but that's mostly a stylistic choice.
Assignment Submission: Video Store API
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
If you didn't get to the functionality the question is asking about, reply with what you would have done if you had completed it.
Reflection
/customers&/videosendpoints? What does the time complexity depend on? Explain your reasoning.POST /rentals/check-inendpoint? What does the time complexity depend on? Explain your reasoning.