2016-08-03 95 views
0

我一直在经历第2章,除了他被要求读者向用户展示第一个微博,这看起来很简单,它一直很顺利。你可以看到章节here迈克尔哈特尔 - 第2章

在我show.html.erb我已经添加了以下行:

<p id="notice"><%= notice %></p> 

<p> 
    <strong>Name:</strong> 
    <%= @user.name %> 
</p> 

<p> 
    <strong>Email:</strong> 
    <%= @user.email %> 
</p 

<p> 
    <strong>Post:</strong> 
    <%= @user.microposts.first %> 
</p> 

<%= link_to 'Edit', edi<p id="notice"><%= notice %></p> 

但是,所有我在看/用户/ 1 “后:#”。

任何想法我做错了什么?

谢谢。

回答

2

<%= @user.microposts.first %>返回单个帖子对象。去渲染内容这样做

<%= @user.microposts.first.content %>

+0

那么,那很简单。谢谢。 –

+0

或者,您可以覆盖'to_s',以便表示帖子的内容。 – Owen

相关问题