Open
Conversation
normancapule
approved these changes
Sep 22, 2022
| post '/add_list_item' => 'list_items#create' | ||
| # post '/add_list_item' => 'list_items#add_list_item' | ||
| post '/edit_list_item' => 'list_items#update' | ||
| get '/list_item/:id/edit' => 'list_items#edit' |
There was a problem hiding this comment.
FYI you can also make use of resources :list_item - https://guides.rubyonrails.org/routing.html#resource-routing-the-rails-default
Comment on lines
+35
to
+37
| def edit | ||
| @list_item = ListItem.find(params[:id]) | ||
| end |
There was a problem hiding this comment.
Why do you need the edit endpoint? Rails already has a show endpoint by default right?
GET /list_item/:id
| validates :book_id, presence: true | ||
| validates :user_id, presence: true | ||
| validates :rating, presence: true, numericality: { in: 1..5 } | ||
| validates :rating, presence: true, numericality: { in: 0..5 } |
There was a problem hiding this comment.
nit
can make use of greater_than and less_than, instead of making rails iterate over a range of values. A bit more performant. But again , this is a nit. Performance is negligible
| }, status: :unauthorized | ||
| end | ||
| render json: { | ||
| status: 200, |
There was a problem hiding this comment.
Why do you need to include the status in the json object? Wouldn't HTTP status 200 already be enough for the frontend to know that it is successful?
1cfae82 to
5a6d34e
Compare
5a6d34e to
e77fbb6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.