3
我正在使用多态性为我的文章,配置文件和照片模型创建评论。下面是我的文章显示页面视图:使用polymorphic_path,得到错误“未定义的方法”合并“”
<div id="comment <%= comment.id %>">
<%= comment.title %>
| <%= link_to "Permalink", polymorphic_path(@commentable, comment), :action => :show %>
| <%= link_to "Reply", polymorphic_path(comment, @comment_child), :action => :new %>
| <%= link_to "Edit Comment", polymorphic_path(@commentable, comment), :action => :edit %>
| <%= link_to 'Delete Comment', [@commentable, comment], :confirm => "Are you sure?", :method => :delete %><br />
<%= comment.content %><br />
<%= comment.user.name %><br /><br />
<%= render :partial => 'comments/comment', :collection => @comment.children %>
</div>
这里是条“秀”控制器:
def show
@article = Article.find(params[:id])
@commentable = Article.find(params[:id])
@comments = @commentable.comments.paginate(:page => params[:page])
@comment = Comment.new
@title = @article.title
end
在这条线出现错误:
| <%= link_to "Permalink", polymorphic_path(@commentable, comment), :action => :show %>
但我确定这个错误出现在所有使用polymorphic_path的其他行中。如果我为article_comment_path交换polymorphic_path,它将起作用。
非常感谢您的帮助。
为什么我不能给予好评这个多! – 2014-11-18 02:33:58