Rails gem for building a commenting systems by using Active Records.
by Peter Wong <email@example.com>
GitHub Project: github.com/peterwongpp/commentem
Better documentation (Making use of rdoc and ri)
If you would like to install it as gem, put this in your Gemfile:
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
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
Fixed the silly typo error on the generated Comment model.
Updated the code of the comment model to use class methods instead of scopes (don't worry, no any change to the usage).
Updated the Readme file.
The Commentem gem is published with basic necessary functionalities (commenting and querying).