我刚刚完成了这个练习并找到了一个可行的解决方案。
首先我更改了 app/views/shared/_user_info.html.erb 以使用 @user 变量(如果已设置),否则使用 current_user 变量。
app/views/shared/_user_info.html.erb:
<% if @user %>
<%= link_to gravatar_for(@user, size: 52), @user %>
<h1>
<%= @user.name %>
</h1>
<span>
<%= link_to "view my profile", @user %>
</span>
<span>
<%= pluralize(@user.microposts.count, "micropost") %>
</span>
<% else %>
<%= link_to gravatar_for(current_user, size: 52), current_user %>
<h1>
<%= current_user.name %>
</h1>
<span>
<%= link_to "view my profile", current_user %>
</span>
<span>
<%= pluralize(current_user.microposts.count, "micropost") %>
</span>
<% end %>
然后我将app/views/users/show_follow.hmtl.erb中的相应信息替换为部分的_user_info.html.erb
app/views/users/show_follow.hmtl.erb:
<div class="row">
<aside class="span4">
<section>
<%= render 'shared/user_info' %>
</section>
<section>
<%= render 'shared/stats' %>
<% if @users.any? %>
<div class="user_avatars">
<% @users.each do |user| %>
<%= link_to gravatar_for(user, size: 30), user %>
<% end %>
</div>
<% end %>
</section>
</aside>
<div class="span8">
<h3><%= @title %></h3>
<% if @users.any? %>
<ul class="users">
<%= render @users %>
</ul>
<%= will_paginate %>
<% end %>
</div>
</div>
我希望这个答案可以帮助任何人学习 M. Hartl 的教程。