-
Notifications
You must be signed in to change notification settings - Fork 0
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
Milestone: #Blog-app Add forms #7
Conversation
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.
Hi @cosywasswa ,
Good job so far!
There are some issues that you still need to work on to go to the next project but you are almost there!
Highlights
✔️ Added a form to add posts, comments, and a way to add likes.
✔️ Implemented actions in post comments and likes controllers to facilitate adding new posts comments and likes.
Required Changes ♻️
Check the comments under the review.
Optional suggestions
Every comment with the [OPTIONAL] prefix is not crucial enough to stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better.
Cheers and Happy coding!👏👏👏
Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Please, remember to tag me in your question so I can receive the notification.
Please, do not open a new Pull Request for re-reviews. You should use the same Pull Request submitted for the first review, either valid or invalid unless it is requested otherwise.
_As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.
app/controllers/posts_controller.rb
Outdated
end | ||
|
||
def new | ||
@user = current_user |
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.
- @cosywasswa Kindly consider removing this code, this is because you are only using it in the create method and this may lead to having a redundant code that doesn't have any use in our codebase.
@@ -0,0 +1,23 @@ | |||
class CommentsController < ApplicationController | |||
def new | |||
@post = Post.find(params[:post_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.
- @cosywasswa Kindly consider removing this code, this is because you are only using it in the create method and this may lead to having a redundant code that doesn't have any use in our codebase.
def comment_params | ||
params.require(:comment).permit(:text) | ||
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.
- [optional] @cosywasswa It would be nice if you made
comment_params
private, this will ensure you havestrong parameters
in your controller that will lead to a more secure application (preventing against mass assignment vulnerabilities, which can occur when a user sends unexpected parameters to a controller action)
config/routes.rb
Outdated
get '/users/:user_id/posts/new', to: 'posts#new', as: 'new_post' | ||
post '/users/:user_id/posts', to: 'posts#create', as: 'create_post' | ||
get '/users/:user_id/posts/:id', to: 'posts#show', as: 'user_post' | ||
resources :users, only: [] do | ||
resources :posts, only: [] do | ||
resources :comments, only: [:new, :create] | ||
resources :likes, only: [:new, :create] | ||
end | ||
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.
- [optional] @cosywasswa It would have been nice if you considered adding a root route in your routes and also refactor your code to only use resources this will make your code easier to read and scale in future
get '/users/:user_id/posts/new', to: 'posts#new', as: 'new_post' | |
post '/users/:user_id/posts', to: 'posts#create', as: 'create_post' | |
get '/users/:user_id/posts/:id', to: 'posts#show', as: 'user_post' | |
resources :users, only: [] do | |
resources :posts, only: [] do | |
resources :comments, only: [:new, :create] | |
resources :likes, only: [:new, :create] | |
end | |
end | |
resources :users, only: [;index, :show, ] do | |
resources :posts, only: [:index, :new, :create, :show] do | |
resources :comments, only: [:new, :create] | |
resources :likes, only: [:new, :create] | |
end | |
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.
Hi @cosywasswa,
Your project is complete! There is nothing else to say other than... it's time to merge it
Congratulations! 🎉
Highlights
- All requested changes are made ✔️
- No linters errors ✔️
- Correct Gitflow ✔️
Optional suggestions
Every comment with the [OPTIONAL] prefix won't stop the approval of this PR. However, I strongly recommend you take them into account as they can make your code better. Some of them were missed by the previous reviewer and addressing them will really improve your application.
Cheers, and Happy coding!👏👏👏
Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Please remember to tag me in your question so I can receive the notification.
As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think the code review was unfair, you can request a second opinion using this form.
👇 I performed the following tasks.
- returns the first user from the database.
-Creating a Post on behalf of the current_user
-Creating a comment on behalf of the current_user