• Stars
    star
    833
  • Rank 54,737 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 16 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The ActiveRecord acts_as_commentable plugin

Acts As Commentable¶ ↑

Provides a single Comment model that can be attached to any model(s) within your app. It creates a Comment model and handles the plumbing between that model and any models that you declare to be commentable models.

Installation :¶ ↑

Add the following line to your Gemfile

Rails 4¶ ↑

gem 'acts_as_commentable'

Rails 3¶ ↑

gem 'acts_as_commentable', '3.0.1'

Rails 2¶ ↑

gem 'acts_as_commentable', git: '[email protected]:jackdempsey/acts_as_commentable.git', branch: '2.x'

Generator¶ ↑

Rails 3+¶ ↑

rails g comment

Rails 2¶ ↑

script/generate comment

Then migrate your database to add the comments model:

rake db:migrate

Make the desired ActiveRecord model act as commentable:

class Post < ActiveRecord::Base
  acts_as_commentable
end

Add a comment to a model instance by adding the following to the controller:

commentable = Post.create
comment = commentable.comments.create
comment.title = "First comment."
comment.comment = "This is the first comment."
comment.save

Fetch comments for the commentable model by adding the following to the view:

commentable = Post.find(1)
comments = commentable.comments.recent.limit(10).all

You can also add different types of comments to a model:

class Todo < ActiveRecord::Base
  acts_as_commentable :public, :private
end

Note: This feature is only available from version 4.0 and above

To fetch the different types of comments for this model:

public_comments = Todo.find(1).public_comments
private_comments = Todo.find(1).private_comments

By default, ‘acts_as_commentable` will assume you are using a `Comment` model. To change this, or change any other join options, pass in an options hash:

class Todo < ActiveRecord::Base
  acts_as_commentable class_name: 'MyComment'
end

This also works in conjunction with comment types:

class Todo < ActiveRecord::Base
  acts_as_commentable :public, :private, { class_name: 'MyComment' }
end

Credits¶ ↑

Xelipe - This plugin is heavily influenced by Acts As Taggable.

Contributors¶ ↑

Jack Dempsey, Chris Eppstein, Jim Ray, Matthew Van Horn, Ole Riesenberg, ZhangJinzhu, maddox, monocle, mrzor, Michael Bensoussan

www.juixe.com/techknow/index.php/2006/06/18/acts-as-commentable-plugin/ www.juixe.com/projects/acts_as_commentable

More Repositories

1

beet

Gem that allows easy production of ruby based projects
Ruby
55
star
2

sequel_polymorphic

Ruby
37
star
3

omniauth-reddit

Ruby
20
star
4

attachmerb_fu

A merb port of the attachment_fu Rails plugin
Ruby
19
star
5

beet-recipes

Ruby
15
star
6

edgeside_chat

Taking the great socket.io example and melding it into the new sprockets and coffeescript abilities of rails 3.1
Ruby
14
star
7

spy

Spy is an Engine that sets up some basic endpoints and adds a middleware to your app for easy user switchings
Ruby
11
star
8

sequel_taggable

A Tag plugin for Sequel::Model's
Ruby
10
star
9

pancake-blog

Ruby
9
star
10

rspec_engine_generator

Ruby
8
star
11

merb-thor

a collection of thor commands for merb
7
star
12

node-beginner-coffee-book

Coffeescript examples for the excellent node beginner book: https://github.com/ManuelKiessling/NodeBeginnerBook
CoffeeScript
6
star
13

builtbythenet

An experiment into social site development
Ruby
5
star
14

merb-sequel-stack

Ruby
5
star
15

find_rails

A standalone Thor script which searchs your app for rails code and provides you with the way to do it in merb.
5
star
16

rails2merb

A helpful tool in identifying areas of code which need conversion
4
star
17

merb-service-example

Small app written on merb edge showing some basics on services
Ruby
4
star
18

vagrant-arch

4
star
19

authlogic_test

3
star
20

letus

A command line tool designed to increase developer productivity. Quickly open Quip docs, create tasks in Asana, and more.
Shell
3
star
21

merb-dev

Useful tools for people actively hacking on Merb
Ruby
3
star
22

attache

Ruby
3
star
23

dm-thor

Thor tasks for DataMapper
3
star
24

self-deprecated

A set of thor tasks to help users easily keep track of API changes across versions of a project
Ruby
3
star
25

nginx-symlink-test

2
star
26

migration_helpers

2
star
27

middleware_test

2
star
28

git-github.com-jackdempsey-.vim

2
star
29

resolvers

A collection of View resolvers for Rails 3
Ruby
2
star
30

opp

Ruby
2
star
31

merb-ar-stack

A Merb stack similar to the supported DM version but with ActiveRecord, Prototype, and TestUnit instead
Ruby
2
star
32

dcrug_presentation

2
star
33

boson-recipes

2
star
34

git_by_doing

Learn Git by Doing It
2
star
35

jackdempsey.github.com

Ruby
2
star
36

todo

2
star
37

cilantro

2
star
38

git-thor

A collection of Thor methods for running various git commands
2
star
39

dot.vim

Vim Script
2
star
40

ember-tweets-example

example app using ember.js to load up some tweets, from article at http://www.adobe.com/devnet/html5/articles/flame-on-a-beginners-guide-to-emberjs.html Also translated the JS into Coffeescript
JavaScript
2
star
41

onion

1
star
42

sprout-core-sample

JavaScript
1
star
43

parental_example

Ruby
1
star
44

waterclojr

1
star
45

.oh-my-zsh

1
star
46

rspec-full-engine

Ruby
1
star
47

lists

Ruby
1
star
48

interested_people

Ruby
1
star
49

issues.dot.js

Add extra functionality to github issues
1
star
50

rails3_acts_as_commetable

Ruby
1
star
51

textmarks

Ruby
1
star
52

any_method_works_on_form_object

Ruby
1
star
53

easy_routing

Ruby
1
star
54

integration-tests-3.1

example showing capybara failing on rails 3.1
Ruby
1
star
55

spy_example

Ruby
1
star
56

avocado

1
star
57

assets

Ruby
1
star
58

koh

Ruby
1
star
59

blog_container

1
star
60

images-engine

Ruby
1
star
61

badger-mobile

1
star
62

basic_shell

Basic shell aliases, prompt info with git, etc
1
star
63

rspec-mounted-engine

Ruby
1
star
64

ember-lists-manager

JavaScript
1
star
65

writeme

Ruby
1
star
66

aac_test

Ruby
1
star