2016-08-03 94 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

相關問題