vendredi 23 février 2018

View a post data through a comment data link not working

I'm having trouble understanding how to give a link through a comment data.

I am trying to display all the comments from the current user(but it displays it two times),if I press "view post" I'm getting an error.

What I need is , if I press a view button to take me to the corresponding post show page,that the comment belongs to

<% current_user.posts.each do |post| %>
  <% current_user.comments.each do |comment| %>
    <p>comment = <%= comment.content %></p>
    <%=link_to "View Post", post,class: "btn btn-default btn-md" %>
  <% end %>
<% end %>

Aucun commentaire:

Enregistrer un commentaire