4

Really basic question about link_to that I'm having trouble finding a straight answer to.

So I have an index view that simply lists posts according to user email address.

<% @post.each do |post| %>
  <tr>
    <td class="email"><%= link_to post.user.email, post %></td>
  </tr>
<% end %>

As it stands, this links to the show view for the given post. How might I make it link to the edit view instead?

neanderslob
  • 2,633
  • 6
  • 40
  • 82

1 Answers1

6

Pretty simple:

<%= link_to post.user.email, edit_post_path(post) %>
Ryan K
  • 3,985
  • 4
  • 39
  • 42