Similar to acts_as_commentable; however, utilizes awesome_nested_set to provide threaded comments
Ruby
Pull request Compare This branch is 6 commits ahead, 62 commits behind elight:master.
Latest commit d85a8dd Dec 28, 2012 Tomasz Warkocki minor fixes
Permalink
Failed to load latest commit information.
lib minor fixes Dec 28, 2012
rails Bumping to maintained version of awesome_nested_set Jul 8, 2011
spec
.gitignore
CHANGELOG fixed issue that prevents the use of the acts_as_voteable plugin Mar 11, 2009
Gemfile
Gemfile.lock
MIT-LICENSE
README.md minor fixes Dec 28, 2012
Rakefile Bump to 1.1.2 Mar 23, 2012
acts_as_commentable_with_threading.gemspec Bump to 1.1.2 Mar 23, 2012
init.rb more porting work for activerecord 3. convert special finders to scop… Sep 24, 2010
install.rb All specs pass already. Awesome. Nov 16, 2008

README.md

Acts As Commentable with Threading

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

This gem is for Rails 3 and later versions only.

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', git: 'git@github.com:codequest-eu/acts_as_commentable_with_threading.git'

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

Usage

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

      @car = Car.find(params[:id])
      @comment = @car.engine_comment_threads.build(:body => "Hey guys this is my comment!")
      @comment.user = current_user
      @comment.save
    
  • 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 car, including child comments:

      @all_comments = @car.engine_comment_threads
    
  • To retrieve only the root comments without their child comments:

      @root_engine_comments = @car.root_engine_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 two things:

Credits

And in turn...

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

More