Skip to content

Conversation

@KanoCode
Copy link
Owner

In this pull request the following was done:

Created a method called current_user inside ApplicationController.

Created forms to perform the following functions:
Creates a Post on behalf of the current_user (use the method that you created in your ApplicationController).
Create a comment on behalf of the current_user (use the method that you created in your ApplicationController).
Allow Users to add likes to Posts.

Copy link

@ShoiraTa ShoiraTa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STATUS: CHANGES REQUIRED 🟡

Hi @KanoCode ,

👍 This is good to make it this far, your project is really nice, congratulations on the good work you have done so far.

Good Points 👍

  • Using nested routes ✔️
  • Descriptive Pull Request ✔️
  • No linter errors ✔️
  • Professional documentation ✔️

There are some issues that you still need to work on to go to the next project but you are almost there!

woohoo-youre-almost

Required Changes ♻️

Check the comments under the review.

Optional suggestions

_Every comment with the [OPTIONAL] prefix won't stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better. Some of them were simply 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 by mentioning my Github username if something is not 100% clear.

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 create
@user = User.find(params[:user_id])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • OPTIONAL: You can just user current_user without targeting params:
 def create
      @post = @current_user.posts.new(post_params)
      @post.likes_counter = 0
      @post.comments_counter = 0
     ...

Comment on lines 36 to 38
def post_params
params.require(:post).permit(:title, :text, :user_id)
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • You should be permitting only title and text, no need to explicitly permit :user_id it can be assigned without permission since it is reference
def post_params
      params.require(:post).permit(:title, :text)
    end

def create
@post = Post.find(params[:post_id])

@comment = @post.comments.new(text: comment_params[:text], user_id: current_user.id, post_id: @post.id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • You should be using comment_params to make sure that only allowed params are assigned.
def create
    @comment = @current_user.comments.new(comment_params)
    @comment.post_id = params[:post_id]
...

Comment on lines +3 to +5
@post = Post.find(params[:post_id])
@like = current_user.likes.new(like_params)
redirect_to user_post_path(user_id: current_user.id, id: @post.id) if @like.save

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Kudos on using current_user here 👏🏻

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ShoiraTa
I will refactor my code

Copy link

@ShoiraTa ShoiraTa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**STATUS: APPROVED 🟢 **


Hi @KanoCode ,

Great work on making the changes 👏🏻

Your project is complete! . There is nothing else to say other than... it's time to merge it 🍾🚢 :shipit: . Congratulations! 🎉💯🌟

5SW

Cheers and Happy coding! 👏 👏 👏

Feel free to leave any questions or comments in the PR thread by mentioning my Github username if something is not 100% clear.


As described in the Code reviews limits policy you have limited number of reviews per this project. If you think that the code review was not fair, you can request a second opinion using this form.

@KanoCode KanoCode merged commit 1302555 into develop Aug 27, 2022
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