In this episode, we start off by fixing a small thing we missed before—actually showing the total comment count in our main comments component. That's just a quick update, simply outputting the count of comments that already exist, so nothing too fancy there.
Then, we move on to adding user avatars to our comments. For this, we dive into the user model and create an avatar helper that generates a URL for the user's avatar. We're using Gravatar for this, which means we need to hash the user's email address (after trimming and lowering the case) and use that hash to construct the avatar URL. If the user has a Gravatar account, their chosen image will show up—otherwise you'll see the default style (which we can change, as shown in the video).
With the avatar helper ready, we head back into our comment component and simply update the image tag to use the avatar helper as the source, using the comment user's name as the alt text. Now, each comment is personalized with its author's avatar. You can tweak or use any service you like, but Gravatar is a popular and really easy choice!