README.md in commentable_on-0.1.0 vs README.md in commentable_on-1.0.0

- old
+ new

@@ -1,10 +1,8 @@ -# _**Under active development**_ - # Commentable On Steroids -Adds comments functionality to Rails/ActiveRecord modules +Adds comments functionality to Rails/ActiveRecord models. It uses the [ancestry gem](https://github.com/stefankroes/ancestry) to add thread/reply support to comments. ## Installation Add this line to your application's Gemfile: @@ -43,22 +41,52 @@ ```ruby @post = Post.find(params[:post_id]) @post.add_comment(commenter: current_user, body: "Awesome") ``` -The commenter, add `acts_as_commenter` to commenter models for reserve functionality +Create reply ```ruby +comment = commenter.first +@post.create_reply(comment: comment, commenter: current_user, body: "awesome reply") +``` + +Get all root comments +```ruby +@post = Post.find(params[:post_id]) +@post.root_comments +``` + +Get all replies for a comment +```ruby +comment = @post.comments.first +@post.replies_for(comment) +``` + +Get thread for a comment +```ruby +comment = @post.comments.first +@post.thread_for(comment) +``` + +The commenter, add `acts_as_commenter` to commenter models +```ruby class User < ActiveRecord::Base acts_as_commenter end ``` Add comment as a commenter ```ruby @post = Post.find(params[:post_id]) current_user.comment(commentable: @post, body: "awesome") ``` + +Reply to comment as a commenter +```ruby +comment = commenter.comments.first +current_user.reply_to(comment: comment, body: "awesome reply") +``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. @@ -79,6 +107,7 @@ ## TO DO - [ ] Add comment threading - [ ] Add migration generators -- [ ] Automate gem release +- [ ] Automate gem release +- [ ] Add contribution guideline