Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Rails gem for building a commenting systems by using Active Records.
tree: 0ed5d1f528

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
.gitignore
README.rdoc
Rakefile
commentem.gemspec
init.rb

README.rdoc

Commentem

Rails gem for building a commenting systems by using Active Records.

by Peter Wong <peter@peterwongpp.com>

GitHub Project: github.com/peterwongpp/commentem


TODO List:

  • Better documentation (Making use of rdoc and ri)

  • Write tests

Installation

Rails 3

If you would like to install it as gem, put this in your Gemfile:

gem 'commentem'

If you would rather like to install it as plugin, run this command in your console:

rails plugin install git://github.com/peterwongpp/commentem.git

And then run:

rails generate commentem
rake db:migrate

Usage

Just add `acts_as_commenter` and `acts_as_commentable` to your models. You could mix them in the same model if you like. See the example below:

# A user can comment on users or posts

class User < ActiveRecord::Base
  acts_as_commenter
  acts_as_commentable
end

class Post < ActiveRecord::Base
  acts_as_commentable
end

# To comment
@user = User.find(1)
@user2 = User.find(2)
@post = Post.find(1)

@user.comment(@user2, "comment goes to here")
@user.comment(@post, "comment goes to here")

@usr.comment(@user, “you could comment on yourself too”)

# To read comments:

@user = User.find(1)
@user2 = User.find(2)
@post = Post.find(1)

@user2.comments
@post.comments

@user.comments # retrieve all comments from @user, including on @user2 and @post
@user.comments_on(@user2) # same as @user2.comments
@user.comments_on(@post) # same as @post.comments

Change Logs

Version 1.0.3

  • Fixed the silly typo error on the generated Comment model.

Version 1.0.2

  • Updated the code of the comment model to use class methods instead of scopes (don't worry, no any change to the usage).

Version 1.0.1

  • Updated the Readme file.

Version 1.0.0

  • The Commentem gem is published with basic necessary functionalities (commenting and querying).

Something went wrong with that request. Please try again.