[openstreetmap/openstreetmap-website] Fixed "Add note and comment counts to the user profile" described in #1643 (PR #4875)
Andy Allan
notifications at github.com
Tue Jun 4 13:21:11 UTC 2024
@gravitystorm commented on this pull request.
> @@ -15,6 +15,7 @@
</li>
<li>
<%= link_to t(".my notes"), user_notes_path(@user) %>
+ <span class='badge count-number'><%= number_with_delimiter(current_user.notes.size) %></span>
They are not generally the same. `current_user` is the currently logged in user, and `@user` is the user whose profile page you are showing.
Now in this specific situation, they are the same user, since they come after an equality check (`if current_user and @user.id == current_user.id`), so they can be used interchangeable - but elsewhere in this file they cannot.
I think the problem here is that although this block is mostly using `current_user` (e.g. for the edits count, 6 lines above), the line immediately above is using `@user`, and so seeing it switch between two lines suggests an error. My initial reaction is that we should use `current_user` throughout the `<!-- Displaying user's own profile page -->` section, for clarity.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4875#discussion_r1625998576
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/4875/review/2096384676 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240604/8bbc470e/attachment.htm>
More information about the rails-dev
mailing list