Project

parrot

0.0
No commit activity in last 3 years
No release in over 3 years
Add simple comments to any Rails resource.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

Parrot Gem: Simple commenting solution for Rails 3 apps.

Installation

  1. Add gem 'parrot' to your Gemfile
  2. Run rake parrot:install:migrations
  3. Run rake db:migrate
  4. Run rails g parrot MODEL_NAME
  5. Add subresources to routes
    resources RESOURCE_NAME do
      resources :parrot_comments, controller: 'parrot/comments', path: 'comments'
    end
    

Notes

Given @comment = Parrot::Comment.find(id):

  • rails g parrot MODEL_NAME (4th step of the installation) adds a parrot_comments class method in the model. It sets a polymorphic relation with Parrot::Comment, whose name is commentable. You can call @post.comments to get related comments, or @comment.commentable to get the related entry of a given comment.
  • The default "author" model is User. You may change it from config/initializers/parrot.rb. You can call @comment.author to get comment's author.
  • User model: has_many :comments, class_name: Parrot::Comment, foreign_key: :author_id
  • Parrot views calls to_s method on the comment's author. You may want to alias it, or the "ugly" Ruby object will be shown: alias_method :to_s, :name
  • You may define after_comment_path method on commentable model for defining where the user should be redirected after commenting (related resource by default).

To-do

  • A Parrot::Thread intermediate object between commentable entries and actual comments would abstract the FKs from the comments, would be the only tier between parrot subsystem and host app, and would make (un)subscriptions dead easy.
  • Not tested.
  • Show partial views examples for showing existing comments and comment form
  • Flash responders working?
  • Wiki: how to reopen parrot's subclasses from parent applications? (to_prepare).

Chef Surfing

parrot was funded by Chef Surfing.