Daniel Brownlow Daniel Brownlow - 4 months ago 26
Ruby Question

Michael Hartl - Chapter 2

I've been going through Chapter 2 and it's been going well, except that he's asked the reader to show the users first micropost, which seems simple. You can see the Chapter here.

In my

show.html.erb
I've added the following lines:

<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>


But all I see at /users/1 is "Post: #".

Any idea what I'm doing wrong?

Thank you.

Answer

<%= @user.microposts.first %> returns a single post object. to render content do this

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