2
<% @post.comments.each do |comment| %>
<p>
<b>Comment:</b>
<%= comment.content %>
</p>
<p>
<b>Commenter</b>
<%= link_to comment.user.username, comment.user %>
</p>
<p>
<b>Link</b>
<%= link_to "Show Post Comment", [@post, :comment] %>
</p>
<% end %>
位指示:
class CommentsController < ApplicationController
def show
@comment = Comment.find(params[:id])
end
等等
路線:
Sandbox3Devise::Application.routes.draw do
resources :posts do
resources :comments
end
等等
如果我點擊ID爲48 後的<%= link_to "Show Post Comment", [@post, :comment] %>
我得到這個:
http://localhost:3000/posts/48/comments/48
任何建議,以解決這一問題?