I now have the acts_as_commentable plugin up on RubyForge. This
plugin will allow you to add comments to any active_record object in
your Rails application.
So far the directions are simple, and there are only a few features:
To install:
ruby script/plugin install
svn://rubyforge.org//var/svn/commentable/acts_as_commentable
In the readme there is a sample migration you will need to use, with
directions on how to modify it if need be. I’m still learning how the
plugins work, and do not know if there is a way to autogenerate this.
Once the migration is completed and ran, you can just add:
acts_as_commentable to those objects you want to comment on and you’re
all set.
Lets say you have a Person object:
class Person < ActiveRecord::Base
acts_as_commentable
end
Then you have a person:
p = Person.find(:first)
Create a comment:
c = Comment.new
Fill out the comment
c.name = “Name of Commentor”
c.content = “What they wrote”
then add it to your object:
p.add_comment©
to remove a comment:
p.remove_comment©
I think that’s everything. This was done quick and dirty, If there
are things you would like to see in this, let me know. I don’t know
if there is much more to do that wouldn’t be application specific.
Thanks
Josh