Open
Conversation
add movies and customer routes
finished tests and methods for customer controller
Ap/movies Index, Show & Create actions and tests
removed show and create methods from customers controller
added custom method/tests to movies model, and updated controller method and tests
Ap/rentals model and tests
remove due date validation on rental model
Video StoreWhat We're Looking For
|
CheezItMan
reviewed
May 24, 2019
| class RentalsController < ApplicationController | ||
|
|
||
| def checkin | ||
| rental = Rental.find_by(customer_id: rental_params[:customer_id], movie_id: rental_params[:movie_id]) |
There was a problem hiding this comment.
How is this changing the Rental status? There's no way to tell in the DB if the rental was checked in!
| @@ -0,0 +1,7 @@ | |||
| class Customer < ApplicationRecord | |||
| has_many :rentals | |||
|
|
|||
There was a problem hiding this comment.
So no method to tell how many movies they have checked out.
| validates :overview, presence: true | ||
| validates :release_date, presence: true | ||
|
|
||
| def set_available_inventory |
There was a problem hiding this comment.
There are ways in Rails to invoke this method when a Movie is created, saved or updated.
| if rental | ||
| render json: {id: rental.id, movie_id: rental.movie.id, customer_id: rental.customer.id}, status: :ok | ||
| else | ||
| render json: [{errors: {rental: ["Rental not found for customer #{rental_params[:customer_id]}, and movie #{rental_params[:movie_id]}"]}}], |
There was a problem hiding this comment.
This line is a bit long, feel free to put in line breaks to make this more readable.
|
|
||
| if rental.save | ||
| rental.set_due_date | ||
| render json: [{ id: rental.id, movie_id: rental.movie.id, customer_id: rental.customer.id, due_date: rental.due_date }], status: :ok |
There was a problem hiding this comment.
This line is also long. You also need to have some impact on the available inventories.
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.
Video Store API
Congratulations! You're submitting your assignment!
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.
Comprehension Questions
POST /rentals/check-inendpoint? What does the time complexity depend on? Explain your reasoning.