Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

link_to post edit view in rails

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?

like image 236
neanderslob Avatar asked Nov 06 '25 12:11

neanderslob


1 Answers

Pretty simple:

<%= link_to post.user.email, edit_post_path(post) %>
like image 89
Ryan K Avatar answered Nov 08 '25 01:11

Ryan K