GithubHelp home page GithubHelp logo

mediaslave24 / acts_as_commentable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jackdempsey/acts_as_commentable

0.0 2.0 0.0 113 KB

The ActiveRecord acts_as_commentable plugin

Home Page: http://juixe.com/svn/acts_as_commentable/

License: MIT License

acts_as_commentable's Introduction

Acts As Commentable

Allows for comments to be added to multiple and different 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:

rake db:migrate

Usage

Make your ActiveRecord model act as commentable:

class Post < ActiveRecord::Base
  acts_as_commentable
end

Add a comment to a model instance:

commentable = Post.create
commentable.comments.create(:title => "First comment.", :comment => "This is the first comment.")

Fetch comments for a commentable model:

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

Add multiple type 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

Fetch comments for a this model:

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

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

More

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

acts_as_commentable's People

Contributors

jackdempsey avatar mickey avatar chriseppstein avatar jinzhu avatar troszok avatar maddox avatar capythebeara avatar davidcollom avatar netbe avatar dontmitch avatar oldwolf avatar oleriesenberg avatar

Watchers

James Cloos avatar Michael avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.