forked from jackdempsey/acts_as_commentable
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
213b09b
commit 490efa8
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Acts As Commentable | ||
================= | ||
|
||
Allows for comments to be added to multiple and different models. | ||
|
||
== Resources | ||
|
||
Install | ||
|
||
Rails | ||
|
||
* To install as a plugin | ||
|
||
** Rails 3: | ||
script/plugin install http://github.com/jackdempsey/acts_as_commentable.git | ||
|
||
** Rails 2: | ||
script/plugin install http://github.com/jackdempsey/acts_as_commentable.git -r 2.x | ||
|
||
|
||
|
||
* To install as a gem | ||
sudo gem install | ||
|
||
Merb/Rails | ||
|
||
* To install as a gem: | ||
Run the following if you haven't already: | ||
gem sources -a http://gems.github.com | ||
|
||
Install the gem(s): | ||
sudo gem install jackdempsey-acts_as_commentable | ||
|
||
add the folloowing line to your environment.rb | ||
config.gem 'jackdempsey-acts_as_commentable', :lib => 'acts_as_commentable', :source => "http://gems.github.com" | ||
|
||
* The gem's have also been pushed to gemcutter.org, so if you have that in your sources, you can just 'gem install acts_as_commentable' | ||
|
||
|
||
Generate your comment model: | ||
|
||
script/generate comment | ||
|
||
Then migrate your database: | ||
|
||
rake db:migrate | ||
|
||
== 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 | ||
|
||
commentable = Model.create | ||
commentable.comments.create(:title => "First comment.", :comment => "This is the first comment.") | ||
|
||
* Fetch comments for a commentable model: | ||
|
||
commentable = Model.find(1) | ||
comments = commentable.comments.recent.limit(10).all | ||
|
||
# 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 |