Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tute/parrot
Simple commenting Rails Engine. Adds commentable behavior to any model easily.
https://github.com/tute/parrot
Last synced: 3 days ago
JSON representation
Simple commenting Rails Engine. Adds commentable behavior to any model easily.
- Host: GitHub
- URL: https://github.com/tute/parrot
- Owner: tute
- License: other
- Created: 2012-04-25T01:33:19.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-12-11T04:28:45.000Z (about 12 years ago)
- Last Synced: 2024-12-24T09:04:56.934Z (15 days ago)
- Language: Ruby
- Homepage:
- Size: 172 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this 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](https://chefsurfing.com/images/embed/logos/chef_surfing_header_logo_medium_red.png)](https://chefsurfing.com/)
parrot was funded by [Chef Surfing](https://chefsurfing.com/).