用gem / Ruby on Rails添加注释 [英] Adding comments with gem/ Ruby on Rails

查看:142
本文介绍了用gem / Ruby on Rails添加注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have been learning some RoR and I have just created my first web application, a photosharing site that is basically a Pinterest copy. Now I am trying to add more functionality and I would like if users would be able to comment pins.

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

I'm using the Commontator Gem: https://github.com/lml/commontator/blob/master/README.md

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

The only problem is that I don't know where to put <%= commontator_thread(commontable) %> in my show.html.erb file. I have tried many different places but for some reason it ends up throwing an exception. Here is my show 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>

如果有人能告诉我应该在哪里放置该链接,我将非常感激。

I would very much appreciate if someone could tell me where I should put that link.

谢谢!

推荐答案

我认为您的问题不在于您将它插入到 show.html.erb 中。您希望能够评论的模型似乎是您的 Pin 模型。如果是这样,文档(位于使用 strong>)表示您首先需要在 Pin 模型中添加 acts_as_commontable

I think your issue here isn't about where you insert it in your show.html.erb. It seems like the model you want to be able to comment on is your Pin model. If so, the documentation (under the section Usage) indicates that you first need to add acts_as_commontable in your Pin model.

然后在 show.html.erb中
$ b

Then in show.html.erb

<%= commontator_thread(@pin) %>

commontable 是模型的一个实例我假设这是 acts_as_commontable @pin

The commontable is a instance of the model that acts_as_commontable which I assume here is @pin

这篇关于用gem / Ruby on Rails添加注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆