以下是我收到的错误图片的链接:
http://gyazo.com/fb646e7da96913eeb5acdf39adfc8865
这是我的UsersController:
class UsersController < ApplicationController
def show
@user = User.find_by_username(params[:id])
end
end
以下是用户个人资料的显示视图:
<strong><%= user.username %></strong> <br>
<strong><%= user.name %></strong>
<div id="things" class="transitions-enabled">
<% @user.things.each do |thing| %>
<div class='panel panel default'>
<div class="box">
<%= link_to image_tag(thing.image.url(:medium)), thing %>
<div class='panel-body'>
<strong><p><%= thing.title %></p></strong>
<p><%= thing.description %></p>
By <%= link_to thing.user.username, thing.user %>
<% if thing.user == current_user %>
<%= link_to edit_thing_path(thing) do %>
<span class='glyphicon glyphicon-edit'></span> Edit
<% end %>
<%= link_to thing_path(thing), method: :delete, data: { confirm: 'Are you sure?' } do %>
<span class='glyphicon glyphicon-trash'></span> Delete
<% end %>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
答案 0 :(得分:2)
<strong><%= @user.username %></strong>
<strong><%= @user.name %></strong>
@user
代替user
阅读Class and Instance Variables In Ruby
并编辑您的HTML代码