asd
asd

Reputation: 345

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.

Upvotes: 0

Views: 49

Answers (1)

mrvncaragay
mrvncaragay

Reputation: 1260

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

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

Upvotes: 2

Related Questions