Rails 3 best way to create a comment system for posts

Philip Benton picture Philip Benton · Sep 2, 2011 · Viewed 9.1k times · Source

my first entry here.

I'm trying to add a comment system to our Posts model. However, I am not sure of the best way to go about it for a number of reasons. I'd like the comment system to be similar to that on Forrst.com but i'd rather have visitors who comment not need an account as the site is our company site not a large community.

Outline of features are:

  1. Visitor can comment on post, entering name, email and comment.
  2. Our team members can comment, i'd like these to be styled differently so would like the system to know it was from one of our team, they will be logged into the system when leaving a comment.
  3. Visitors and team members can reply to a comment. The system needs to know which comment it was in reply to.
  4. Lastly i'd like the system to know if the comment was written by the post author.

I have looked and been trying out acts_as_commentable_with_threading which seems perfect except everyone needs a user account to leave a comment, something I am trying to avoid unless anyone has other thoughts on that?

I have also implemented this myself by creating a comments model and using awesome_nested_set for the threading. Within the comments model I have a user_id which is only populated if the user is logged in (meaning they must be a team member), this seems a little messy though.

Does anyone have any thoughts on this?

Oh, and I would love each person to be notified of a reply to their comment (if pos).

Thanks in advance.

Answer

HiteshRawal picture HiteshRawal · Sep 2, 2011

There are lot of tools available to post comments and working with ruby on rails.

http://ruby-toolbox.com/categories/rails_comments.html

also you can customize according your own requirement instead of writing a messy code.