-
Notifications
You must be signed in to change notification settings - Fork 24
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
VideoStoreAPI - Pipes - Rebecca and Bennett #5
base: master
Are you sure you want to change the base?
Conversation
create customers model and controller
movies model
… into movie-model
add basic controller actions, tests, and model validation for movie
Customertests
fix tests to have different way of collecting params
rentals checkout action and rentals fixtures
basic not dry version of history/current routes
rentals controller
add test for customers controller index
Video StoreWhat We're Looking For
|
else | ||
render( | ||
json: { errors: { | ||
customers: ["No customers 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.
While this behavior isn't technically wrong, the convention in a case like this is to consider it successful and return an empty array.
status: :ok | ||
) | ||
rental.customer.movies_checked_out_count +=1 | ||
rental.movie.available_inventory -= 1 |
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.
In order to update the values in the DB, you'll have to call save
on rental.customer
and rental.movie
. If you're looking for some additional reading, this sort of situation (where several models need to be updated all at once) is a good candidate for wrapping in a database transaction.
This sort of logic would be great as a model method - perhaps a model filter (similar to a controller filter, but happens before writing to the DB).
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.
The other option here would be to not track these as separate columns in the DB, but generate them dynamically whenever they're needed by counting rentals associated with this movie/customer.
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
*We didn't fully finish the checkin/checkout optionals and testing so they might not be totally covered.