Skip to content
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

Merged
merged 25 commits into from
Sep 27, 2023
Merged

Milestone: #Blog-app Add forms #7

merged 25 commits into from
Sep 27, 2023

Conversation

cosywasswa
Copy link
Owner

👇 I performed the following tasks.

  • Created a method called current_user in your ApplicationController
    - returns the first user from the database.
  • Created forms to perform the following functions:
    -Creating a Post on behalf of the current_user
    -Creating a comment on behalf of the current_user
  • Users can add likes to Posts.
  • Updated README file with updates.
  • Fixed linter bugs.

Copy link

@danmainah danmainah left a 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.

end

def new
@user = current_user

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])

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.

Comment on lines +20 to +22
def comment_params
params.require(:comment).permit(:text)
end

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 have strong 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
Comment on lines 5 to 13
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

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
Suggested change
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

Copy link

@cynthiainga cynthiainga left a 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 :shipit:
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.

@cosywasswa cosywasswa merged commit bcf75a2 into develop Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants