Commentui
A simple comment API gem
Installation
1. Gem install
Add this line to your application's Gemfile:
gem 'commentui', "~> 0.1"
And then execute:
$ bundle install
Or install it yourself as:
$ gem install commentui
2. Migrations
Run the following command to copy Commentui's migrations to your application:
$ bundle exec rake commentui:install:migrations
Then run migrate database command:
$ rake db:migrate
To remove engine migration, run:
$ rake db:migrate SCOPE=commentui VERSION=0
3. Initializers
Run the following command to copy Commentui's initializers to your application:
$ bundle exec rake commentui:install:initializers
4. Route config
Add this line to your Rails application's routes.rb file:
mount Commentui::Engine => '/commentui'
Usage
1. Models
Add this line to your model(s) should be able to post comments (usually user model):
acts_as_commentuier
The model'll look like:
class User < ApplicationRecord
acts_as_commentuier
end
Add this line to any models you want to be able to comment on (post,...)
acts_as_commentuiable
The model'll look like:
class Post < ApplicationRecord
acts_as_commentuiable
end
2. Controllers
Supported actions
Helper | HTTP Verb | Path | Controller#Action |
---|---|---|---|
thread_comments_path | GET | /threads/:thread_id/comments(.:format) | commentui/comments#index |
POST | /threads/:thread_id/comments(.:format) | commentui/comments#create | |
thread_comment_path | GET | /threads/:thread_id/comments/:id(.:format) | commentui/comments#show |
PATCH | /threads/:thread_id/comments/:id(.:format) | commentui/comments#update | |
PUT | /threads/:thread_id/comments/:id(.:format) | commentui/comments#update | |
DELETE | /threads/:thread_id/comments/:id(.:format) | commentui/comments#destroy | |
thread_path | GET | /threads/:id(.:format) | commentui/threads#show |
Contributing
Contribution directions go here.
License
The gem is available as open source under the terms of the MIT License.