我想在我的应用程序中列出用户所有评论的仪表板。我遇到的问题是,当我点击用户提交评论的帖子时,它将我带到所有帖子的索引页面,而不是特定帖子的显示页面。这是我与<td><%= link_to review.post.title , posts_path(@post) %></td>
有问题的代码行。这里是我的代码:link_to显示页面将我带到索引页面Rails?
的意见/页/ dashboard.html.erb
<div class="align-left">
<div class="col-md-2">
<h5><%= @user.name %></h5>
</div>
<div class="col-md-5">
<h3>My Posts</h3>
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Created</th>
<th></th>
</tr>
</thead>
<tbody>
<% @posts.each do |post| %>
<tr>
<td><%= post.title %></td>
<td><%= time_ago_in_words(post.created_at) %> ago</td>
<td><%= link_to "Edit", edit_post_path(post) %>|<%= link_to "Destroy", post_path(post), method: :delete %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<br>
<h3>My Reviews</h3>
<table class="table table-hover">
<thead>
<tr>
<th>Place</th>
<th>Created</th>
<th></th>
</tr>
</thead>
<tbody>
<% @reviews.each do |review| %>
<tr>
<td><%= link_to review.post.title , posts_path(@post) %></td>
<td><%= time_ago_in_words(review.created_at) %> ago</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
斜掠路由文件
也'应该工作 – hamitron