VideoStoreAPI - Pipes - Rebecca and Bennett#5
VideoStoreAPI - Pipes - Rebecca and Bennett#5bennettrahn wants to merge 44 commits intoAda-C8:masterfrom
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.
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.
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.
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.