Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add changes from Barry by moving directory straight over from spaced-…
…ed rails2.3 project
- Loading branch information
John Metta
committed
May 23, 2012
1 parent
3a1537d
commit 9506eb0
Showing
23 changed files
with
255 additions
and
335 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pkg | ||
*.gem | ||
.DS_Store |
Empty file.
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,65 @@ | ||
Acts As Commentable | ||
================= | ||
|
||
Allows for comments to be added to multiple and different models. | ||
|
||
== Resources | ||
|
||
Install | ||
|
||
* To install as a plugin: | ||
|
||
script/plugin install http://juixe.com/svn/acts_as_commentable | ||
|
||
* 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 | ||
|
||
* 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 |
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,73 @@ | ||
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.git | ||
|
||
* 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" | ||
|
||
|
||
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 |
This file was deleted.
Oops, something went wrong.
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
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
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,13 @@ | ||
class CommentGenerator < Rails::Generator::Base | ||
def manifest | ||
record do |m| | ||
m.directory 'app/models' | ||
m.file 'comment.rb', 'app/models/comment.rb' | ||
m.migration_template "create_comments.rb", "db/migrate" | ||
end | ||
end | ||
# ick what a hack. | ||
def file_name | ||
"create_comments" | ||
end | ||
end |
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 |
---|---|---|
|
@@ -12,4 +12,5 @@ class Comment < ActiveRecord::Base | |
|
||
# NOTE: Comments belong to a user | ||
belongs_to :user | ||
|
||
end |
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
Empty file.
Empty file.
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
Oops, something went wrong.