-
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
Heather (Ports) and Jansen (Sockets) #29
base: master
Are you sure you want to change the base?
Conversation
… All tests passing
Video StoreWhat We're Looking For
|
|
||
def zomg | ||
render json: { message: "It works!" } | ||
end |
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.
Oh goshers. You didn't need to leave this in. :P
customer = Customer.find_by(id: params[:customer_id]) | ||
|
||
if movie.nil? && customer.nil? | ||
render status: :not_found, json: { errors: ["Customer with id #{params[:customer_id]} was not found.", "Movie with id #{params[:movie_id]} was not found"] } |
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.
Small style note: not all text editors wrap lines for you. This line is so long that on GitHub I have to scroll horizontally to see all the pieces. You can make this easier to read by putting a newline after any given comma in a statement.
class RentalsController < ApplicationController | ||
def check_out | ||
movie = Movie.find_by(id: params[:movie_id]) | ||
customer = Customer.find_by(id: params[:customer_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.
You have a bunch of business logic here! Would it be possible to encapsulate this in a model method? Something like
rental.check_out(customer_id, movie_id)
might be a good interface. That would make this logic easier to test as well.
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.