首页 > 解决方案 > 使用acts_as_commentable 和acts_as_votable ROR

问题描述

我正在尝试在我的 rails 应用程序中同时使用acts_as_commentable_with_threading 和acts_as_votable gem。

我不确定如何执行在我的应用程序正在使用的acts_as_commentable_with_threading gem 文件上打开“acts_as_votable”所需的步骤。

gem 的自述文件说明如下:"If you plan to use the acts_as_votable plugin with your comment system be sure to uncomment the line acts_as_votable in lib/comment.rb."

我尝试执行以下操作,但仍然出现错误。

首先解压gem:

gem unpack acts_as_commentable_with_threading

第二次编辑comment.rb 文件,以取消注释“acts_as_votable”行。

第三次尝试让捆绑器使用保存在我的 /app 文件夹上方的 gem 的本地副本:

gem "acts_as_commentable_with_threading", path: "acts_as_commentable_with_threading-2.0.1"

然后运行捆绑安装。使用 votable gem 提供的 get_upvotes 方法时,出现以下错误:

undefined method `get_upvotes' for #<Comment:0x00007fa37dbf13f0>

标签: ruby-on-railsrubygemsacts-as-votableacts-as-commentable

解决方案


推荐阅读