acts_as_commentable_with_threading

Similar to acts_as_commentable; however, utilizes awesome_nested_set to provide threaded comments

  • 所有者: elight/acts_as_commentable_with_threading
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Build Status
Code Climate

Acts As Commentable (now with comment threads(TM)!!! -- kidding on the (TM))

Allows for threaded comments to be added to multiple and different models.
Drop-in compatible for acts_as_commentable (however requiring a database
schema change)

Requirements

The 2.x version of this gem is for Rails 4 and later versions only. For the Rails 3.x compatible version of this gem, please use version 1.2.0.

This gem depends on CollectiveIdea's Awesome Nested Set gem. It is installed if
not already present when you install this gem.

You can find the gem on GitHub at collectiveidea/awesome_nested_set

Install

In your Gemfile, add:

gem 'acts_as_commentable_with_threading'

and run bundle install.

Migrations

  • To install from scratch:

      rails generate acts_as_commentable_with_threading_migration
    

    This will generate the migration script necessary for the table

  • To upgrade to acts_as_commentable_with_threading from the
    old acts_as_commentable:

      rails generate acts_as_commentable_upgrade_migration
    

    This will generate the necessary migration to upgrade your comments
    table to work with acts_as_commentable_with_threading

If the generators fail, you can just as easily create the migrations by hand.
See the templates in the generators under lib/generators.

Usage

class Article < ActiveRecord::Base
  acts_as_commentable
end
  • Add a comment to a model instance, for example an Article:

      @article = Article.find(params[:id])
      @user_who_commented = @current_user
      @comment = Comment.build_from( @article, @user_who_commented.id, "Hey guys this is my comment!" )
    
  • To make a newly created comment into a child/reply of another comment:

      @comment.move_to_child_of(the_desired_parent_comment)
    
  • To retrieve all comments for an article, including child comments:

      @all_comments = @article.comment_threads
    
  • To retrieve only the root comments without their child comments:

      @root_comments = @article.root_comments
    
  • To check if a comment has children:

      @comment.has_children?
    
  • To verify the number of children a comment has:

      @comment.children.size
    
  • To retrieve a comment's children:

      @comment.children
    
  • 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.

Credits

And in turn...

  • Xelipe - Because acts_as_commentable was heavily influenced by Acts As Taggable.

More

主要指標

概覽
名稱與所有者elight/acts_as_commentable_with_threading
主編程語言Ruby
編程語言Ruby (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2008-11-16 14:37:39
推送於2022-05-08 16:45:46
最后一次提交2015-12-26 14:06:37
發布數8
最新版本名稱v2.0.1 (發布於 2015-12-22 22:26:31)
第一版名稱0.1.0 (發布於 2008-11-16 15:03:22)
用户参与
星數672
關注者數17
派生數165
提交數131
已啟用問題?
問題數65
打開的問題數17
拉請求數36
打開的拉請求數3
關閉的拉請求數14
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?