-
Notifications
You must be signed in to change notification settings - Fork 26
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
Amy^2 #16
base: master
Are you sure you want to change the base?
Amy^2 #16
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
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is also long. You also need to have some impact on the available inventories.
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-in
endpoint? What does the time complexity depend on? Explain your reasoning.