Skip to content
The ActiveRecord acts_as_commentable plugin
Ruby
Pull request Compare This branch is 33 commits behind jackdempsey:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
rails
tasks
test
.gitignore
.rvmrc
CHANGELOG
Gemfile
Gemfile.lock
MIT-LICENSE
README.rdoc
Rakefile
acts_as_commentable.gemspec
init.rb
install.rb

README.rdoc

Acts As Commentable

Allows for comments to be added to multiple and different models.

Installation :

Add the following line to your Gemfile

Rails 4

gem 'acts_as_commentable'

Rails 3

gem 'acts_as_commentable', '3.0.1'

Rails 2

gem 'acts_as_commentable', git: 'git@github.com:jackdempsey/acts_as_commentable.git'  , branch: '2.x'

Generator

Rails 3+

rails g comment

Rails 2

script/generate comment

Then migrate your database:

rake db:migrate

Usage

Make your ActiveRecord model act as commentable:

class Post < ActiveRecord::Base
  acts_as_commentable
end

Add a comment to a model instance:

commentable = Post.create
commentable.comments.create(:title => "First comment.", :comment => "This is the first comment.")

Fetch comments for a commentable model:

commentable = Post.find(1)
comments = commentable.comments.recent.limit(10).all

Add multiple type of comments to a model:

class Todo < ActiveRecord::Base
  acts_as_commentable :public, :private
end

Note: This feature is only available from version 4.0 and above

Fetch comments for a this model:

public_comments = Todo.find(1).public_comments
private_comments = Todo.find(1).private_comments

Credits

Xelipe - This plugin is heavily influenced by Acts As Taggable.

Contributors

Jack Dempsey, Chris Eppstein, Jim Ray, Matthew Van Horn, Ole Riesenberg, ZhangJinzhu, maddox, monocle, mrzor, Michael Bensoussan

More

www.juixe.com/techknow/index.php/2006/06/18/acts-as-commentable-plugin/ www.juixe.com/projects/acts_as_commentable

Something went wrong with that request. Please try again.