Leti & Maddie - VideoStoreAPI - Ampers#21
Conversation
…to rental-model
…to ms_feature-rentals-controller
…passing on smoke test, but there is still 2 failing
…customer controller
… attribute instead of calling the assign_due_date_method.
…to ms_feature-sort
| has_many :rentals | ||
|
|
||
| def available_inventory | ||
| if self.inventory |
There was a problem hiding this comment.
Why would self.inventory ever not be true?
Video StoreWhat We're Looking For
f--F-F-FAAANCY pagination work!!! Also rabl working, nice! I think that the project looks good -- I think the model and controller tests are pretty thorough In your fixtures files, like Otherwise, looks good -- I think there are some really nice stylistic things that you all did that I'll comment on! |
| end | ||
|
|
||
| else | ||
| render json: {ok: false, errors: "This will not work"}, status: :bad_request |
There was a problem hiding this comment.
The phrase "This will not work" is a little awkward sounding?
| class MoviesController < ApplicationController | ||
| def index | ||
|
|
||
| params[:sort] ? (sort = params[:sort].to_sym) : sort = :id |
There was a problem hiding this comment.
this line is great! I'm a fan!
Ternaries also work so you can assign things like this (this does the same thing you did):
sort = params[:sort] ? params[:sort].to_sym : :id|
|
||
| @movie = Movie.find_by(id: params[:id]) | ||
|
|
||
| render json: {ok: false, error: :not_found}, status: :not_found if @movie.nil? |
There was a problem hiding this comment.
these post-fix conditionals look really fancy and nice!
| # scope :by_name, -> (name) { where(name: name) } | ||
|
|
||
| def movies_checked_out_count | ||
| return Rental.where(customer_id: self.id).where(returned: false).count |
There was a problem hiding this comment.
This might be an instance where instead of Rental.where(customer_id: self.id) you could use self.rentals, if you find a way to filter on these with returned == false (maybe .filter?)
There was a problem hiding this comment.
Then again, I see the benefit in the style you wrote it in already here
| font-size: 30px; | ||
| } | ||
|
|
||
| .about-me { |
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