elight / acts_as_commentable_with_threading
- Source
- Commits
- Network (11)
- Issues (2)
- Downloads (2)
- Wiki (1)
- Graphs
-
Tree:
ae35d03
commit ae35d034ffa6d751b4a1a2ea7a150897d692e413
tree 2016ae04f3a6a69918b6c91ccee8f255383681bc
parent c60f773556a1f0d05818d6b6dc87ea8a1e43d423 parent 20268982d37af48a8a622023ea691f5f1388d068
tree 2016ae04f3a6a69918b6c91ccee8f255383681bc
parent c60f773556a1f0d05818d6b6dc87ea8a1e43d423 parent 20268982d37af48a8a622023ea691f5f1388d068
| name | age | message | |
|---|---|---|---|
| |
CHANGELOG | ||
| |
MIT-LICENSE | Sun Nov 16 09:01:14 -0800 2008 | |
| |
README | ||
| |
Rakefile | Sun Nov 16 09:01:14 -0800 2008 | |
| |
acts_as_commentable_with_threading.gemspec | Sun Nov 16 12:15:08 -0800 2008 | |
| |
init.rb | Sun Nov 16 09:01:14 -0800 2008 | |
| |
install.rb | Sun Nov 16 09:01:14 -0800 2008 | |
| |
lib/ | Wed Mar 11 08:50:32 -0700 2009 | |
| |
spec/ | Sun Nov 16 09:08:33 -0800 2008 |
README
Acts As Commentable (now with comment threads (TM)!!! -- kidding on the (TM))
===================
Allows for threaded comments to be added to multiple and different models. Drop-in compatible for acts_as_commentable
(however requiring a database schema change)
***NOTE: This plugin requires that you also install the awesome_nested_set plugin.
script/plugin install git://github.com/collectiveidea/awesome_nested_set.git
== Resources
Install
Rails
* To install as a plugin:
script/plugin install git://github.com/elight/acts_as_commentable_with_threading.git
* Create a new rails migration and add the following self.up and self.down methods
* These are the required fields for the database migration, however you may add any additional fields you need.
def self.up
create_table "comments", :force => true do |t|
t.integer "commentable_id", :default => 0
t.string "commentable_type", :limit => 15, :default => ""
t.text "body", :default => ""
t.integer "user_id", :default => 0, :null => false
t.integer "parent_id"
t.integer "lft"
t.integer "rgt"
t.timestamps
end
add_index "comments", "user_id"
add_index "comments", "commentable_id"
end
def self.down
drop_table :comments
end
== Usage
class Model < ActiveRecord::Base
acts_as_commentable
end
* Add a comment to a model instance, for example an Article
@article = Article.find(params[:id])
@user_who_commented = @current_user
@comment = Comment.build_from(@article, @user_who_commented.id, "Hey guys this is my comment!" )
* To make a newly created comment into a child/reply of another comment
comment.move_to_child_of(the_desired_parent_comment)
* To retrieve all comments for an article, including child comments
@all_comments = @article.comment_threads
* To retrieve only the root comments without their children comments
@root_comments = @article.root_comments
* To check if a comment has children
@comment.has_children?
* To verify the number of children a comment has
@comment.children.size
* To retrieve a comments children
@comment.children
*If you plan to use the acts_as_voteable plugin with your comment system be sure to uncomment two things:
in lib/comment.rb uncomment the line "acts_as_voteable"
in lib/acts_as_commentable_with_threading.rb uncomment the line "include Juixe::Acts::Voteable" near the top
== Credits
Jack Dempsey - This plugin/gem is heavily influenced/liberally borrowed/stole from acts_as_commentable
which in turn credits....
Xelipe - Because acts_as_commentable was heavily influenced by Acts As Taggable.
== More
http://triple-dog-dare.com
http://evan.tiggerpalace.com
