Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Remove 'Follow' button from the current users profile so they can't follow themselves?

Hi all. How can I remove the 'Follow' button from the individuals own profile? (The person who is currently logged in) I don't want them to be able to follow themselves. Thanks in advance!

User / Show

<% provide(:title, @user.name) %>

 <div class="row">
<aside class="span4">
            <%= image_tag @user.avatar.url(:thumb) %>
            <%= @user.name %>

      <%= render 'users/stats' %>

    <% if current_user.following?(@user) %>
    <%= render 'users/unfollow' %>
    <% else %>
    <%= render 'users/follow' %>
    <% end %>

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I would go for an unless statement around the follow button, something like:

<% unless @user == current_user %>
<% end %>

Ahh I had <% unless user == current_user %>. I was missing the @ symbol. Thank you so much again!!!