Skip to content

marksim/commentator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commentator

Commentator is a Rails Engine for adding commenting to any page/model in your app.

Installation

Install the gem

gem install commentator

Or in your Gemfile

gem 'commentator'

Configuration

rake commentator # Installs the DB Migration
# in config/routes.rb
mount Commentator::Engine => "/commentator"
# in application.js 
//= require commentator/comments
# in application_controller.rb
def authorize_comment
  # you have access to @commentable
  true # Your logic here
end
# in config/initializer.rb
Commentator.configure do |config|
  # config.owner_class = "User"
  # config.current_commenter_method = :current_user
  config.authorize_method = :authorize_comment
end

Usage

# In any model
class MyModel < ActiveRecord::Base
  include Commentator::Model
end

my_model.comments
# in any view
# @my_model.class_name + @my_model.id is the key for which comments to look up
<%= comments_for(@my_model) %>

# Not working yet - for comments not tied to a model, but tied to a page
# :about_us is the key for which comments to look up
<%= comments_for(:about_us) %>

Examples

In Views

# No new comments or replies
= comments_for(@my_model, :read_only => true)

# Replies to existing comments only
= comments_for(@my_model, :replies_only => true)

# No Nested Comments
= comments_for(@my_model, :no_replies => true)

In code

# if Commentator::Model is included in the model, you get
my_model.comments

About

Easy comments on any page in Rails

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published