2013-12-08 134 views
0

我一直在学习一些RoR,并且我刚刚创建了我的第一个Web应用程序,一个基本上是Pinterest副本的照片共享网站。现在我正在尝试添加更多功能,并希望用户能够评论引脚。使用gem/Ruby on Rails添加评论

我使用的Commontator宝石:https://github.com/lml/commontator/blob/master/README.md

唯一的问题是,我不知道在哪里把<%= commontator_thread(commontable) %> 我show.html.erb文件。我尝试了很多不同的地方,但由于某种原因,它最终抛出了一个异常。这里是我的秀html.erb:

<%= link_to 'Back', pins_path %> 

<div class="row"> 
    <div class="col-md-offset-2 col-md-8"> 
    <div class="panel panel-default"> 
     <div class="panel-heading center"> 
     <%= image_tag @pin.image.url(:medium) %> 
     </div> 
     <div class="panel-body"> 
     <p><%= @pin.description %></p> 
     <p><strong><%= @pin.user.name if @pin.user %></strong></p> 




     <%= link_to edit_pin_path(@pin) do %> 
     <span class="glyphicon glyphicon-edit"></span> 
     Edit 


     <% end %> 



     </div> 
    </div> 
    </div> 
</div> 

我非常感谢,如果有人能告诉我我应该把那个链接放在哪里。

谢谢!

+2

它的实际位置应该是灵活的。你确定你正确地遵循了宝石的整个设置吗?我几乎可以肯定,它会抛出一个异常,因为您尝试调用缺少的方法。 – Severin

回答

1

我认为你的问题不在于你在哪里插入show.html.erb。看起来你想要评论的模型是你的Pin模型。如果是这样,documentation(在部分用法)表示您首先需要在您的引脚模型中添加acts_as_commontable

然后在show.html.erb

<%= commontator_thread(@pin) %> 

commontable是模型的实例acts_as_commontable我以为这里是@pin