• Stars
    star
    672
  • Rank 67,180 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 16 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

coulda

Given-when-then for Test::Unit (or "If shoulda and cucumber had a baby")
Ruby
144
star
2

yourdsl

~1/2 of a compiler for an internal DSL: a lexer and partial parser for contextual internal DSLs
Ruby
22
star
3

modest_presenter

A simple Presenter for use with arbitrary templating languages
Ruby
12
star
4

rb-skypemac

Ruby API to Skype via Skype's AppleScript API
Ruby
11
star
5

jrsplenda

Sweetens up JRuby Mocha with several helpers to simplify testing Java from Ruby
Ruby
7
star
6

slack_emoticon_inhaler

Chrome extension that automatically downloads every emoticon on a Slack's customize/emoji page
JavaScript
6
star
7

coulda_web_steps

capybara and factory_girl-based web steps for coulda
Ruby
5
star
8

.emacs.d

My humble little emacs config
Emacs Lisp
5
star
9

pairing-server

My Vagrant Rackspace Ruby EMACS pairing env
Ruby
3
star
10

twitterbot--public-dms

Echoes received DMs to it's public timeline
Ruby
3
star
11

twitter--follow-my-followers

Follows twitter users who follow the auth'd user
Ruby
3
star
12

ruby-quiz-74

Markov Chaining while teaching teh TDDz to joblesspirate
Ruby
2
star
13

conway-erlang

Erlang
2
star
14

autodroid

A partly working car-dock-based app to provide a highly usable UI for tasks when driving. Currently provides a custom user interface for playing Music.
Java
2
star
15

ruby-conway

A Ruby Conway's Game of Life implementation with a Ruby Proessing visualizer
Ruby
2
star
16

pickleberry_pie

Rails 3 app for Pickleberry Pie, a 501(c)3
Ruby
2
star
17

rbwikipedia-film

Provides a simple API for finding an extracting basic metadata about films (including movie posters) from wikipedia
Ruby
2
star
18

Conway-s-Game-of-Life-in-Javascript

Obsessively hacking away at Conway's Game of Life but now in JS
JavaScript
2
star
19

vim_runtime

Vim Script
1
star
20

remote_jobs

JavaScript
1
star
21

everything

Yes, everything
Ruby
1
star
22

vim

Vim Script
1
star
23

dot.emacs

Emacs Lisp
1
star
24

describe

Hub project for distilling nested specs down to just the specs, ma'am.
Ruby
1
star
25

rubywarrior_marshall

Killing my warrior, Marshall, again and again as he attempts to traverse the evil dungeon of @rbates' rubywarrior
Ruby
1
star
26

mongomapper-rails3-branch-example

Skeleton app using the latest from mongo_mapper rails3 branch
Ruby
1
star
27

gem-skeleton-minitest

Ruby
1
star
28

fog-rackspace

WIP extraction of Rackspace provider from fog gem into a separate gem living under fog
Ruby
1
star