Skip to content

oldwolf/acts_as_commentable

 
 

Repository files navigation

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

Add the following line to your Gemfile

gem 'acts_as_commentable'
gem 'acts_as_commentable', '3.0.1'
gem 'acts_as_commentable', git: '[email protected]:jackdempsey/acts_as_commentable.git'  , branch: '2.x'
rails g comment
script/generate comment

Then migrate your database:

rake db:migrate

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

Fetch comments for a this model:

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

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

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

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

About

The ActiveRecord acts_as_commentable plugin

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Ruby 100.0%