簡體   English   中英

使用gem / Ruby on Rails添加評論

[英]Adding comments with gem/ Ruby on Rails

我一直在學習一些RoR,並且剛創建了我的第一個Web應用程序,即一個照片共享網站,基本上是Pinterest副本。 現在,我正在嘗試添加更多功能,我希望用戶是否能夠評論圖釘。

我正在使用Commontator寶石: https : //github.com/lml/commontator/blob/master/README.md

唯一的問題是我不知道在show.html.erb文件中的<%= commontator_thread(commontable) %>放在哪里。 我嘗試了很多不同的地方,但是由於某種原因,它最終拋出了異常。 這是我的節目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>

如果有人能告訴我該鏈接的位置,我將不勝感激。

謝謝!

我認為您的問題與您將其插入show.html.erb中的位置無關 您似乎想要評論的模型是Pin模型。 如果是這樣,則文檔 (在“ 用法 ”部分下)表明您首先需要在Pin模型中添加acts_as_commontable

然后在show.html.erb中

<%= commontator_thread(@pin) %>

commontable是模型的實例acts_as_commontable我以為這里@pin

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM