This is my code for a profile panel that I am working on for a project. I am still new to rails and I just started to use gravatar. And when I ran the panel I get a random person on the image. I have never seen this person before, and no idea who they are. How does that happen?
<nav class="panel">
<p class="panel-heading">
Profile
</p>
<p class= "panel-block">
<article class="media">
<div class="media-left">
<figure class="image is-64x64">
<%= gravatar_image_tag(current_user.email, size: 64, alt: current_user.name) %>
</figure>
</div>
<div class="media-content">
<div class="content">
<p>
<strong><%= current_user.name %></strong><br/>
<small><%= current_user.username %></small>
</p>
</div>
</div>
</article>
</p>
</nav>
When I do inspect element, I get this link for a specific avatar from gravatar. Have I been hacked? Looking forward for your help!
<img size="64" alt="fireball" src="http://gravatar.com/avatar/c3f5511d8046fc67693d50b0473c1a85" width="80" height="80">
You Aren't getting the proper image maybe because of wrong setup! Let's fix it.
We'll start from the scratch!
Let's check the application helpers file in app/helpers/application_helpers.rb You can also follow this method by adding the following lines inside of the ApplicationHelper module:
HERE inside of the def gravatar_for,
imgtag that what this tag will contain! you can set the class here too for every gravatar image tag.NOW, add the following tag in your code where this is needed to render!
HERE:
Now this will work. I guess you will find helpful for every users Gravatar image setup including current user also.
Thanks for reading this. If anything else you need from Gravatar, this is also helpful by editing this slightly.
Happy Railings