public
Description: The ActiveRecord acts_as_commentable plugin
Homepage: http://juixe.com/svn/acts_as_commentable/
Clone URL: git://github.com/jackdempsey/acts_as_commentable.git
100644 72 lines (48 sloc) 1.783 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Acts As Commentable
=================
 
Allows for comments to be added to multiple and different models.
 
== Resources
 
Install
 
  Rails
 
   * To install as a plugin:
 
    script/plugin install http://github.com/jackdempsey/acts_as_commentable
 
  Merb/Rails
  
   * To install as a gem:
 
   rake install
 
 * Create a new rails migration and add the following self.up and self.down methods
 
  def self.up
    create_table "comments", :force => true do |t|
      t.column "title", :string, :limit => 50, :default => ""
      t.column "comment", :text, :default => ""
      t.column "created_at", :datetime, :null => false
      t.column "commentable_id", :integer, :default => 0, :null => false
      t.column "commentable_type", :string, :limit => 15, :default => "", :null => false
      t.column "user_id", :integer, :default => 0, :null => false
    end
  
    add_index "comments", ["user_id"], :name => "fk_comments_user"
  end
 
  def self.down
    drop_table :comments
  end
 
== Usage
 Merb Users:
 * add 'dependency "acts_as_commentable"' to your init.rb or dependencies.rb if using merb-stack
 
 * Make your ActiveRecord model act as commentable.
 
 class Model < ActiveRecord::Base
   acts_as_commentable
 end
 
 * Add a comment to a model instance
 
 model = Model.new
 comment = Comment.new
 comment.comment = 'Some comment'
 model.comments << comment
 
 # Following doesn't work/make sense to me. Leaving for historical sake -- Jack
 # * Each comment reference commentable object
 #
 # model = Model.find(1)
 # model.comments.get(0).commentable == model
 
== Credits
 
Xelipe - This plugin is heavily influenced by Acts As Taggable.
 
== More
 
http://www.juixe.com/techknow/index.php/2006/06/18/acts-as-commentable-plugin/
http://www.juixe.com/projects/acts_as_commentable