Skip to content

Instantly share code, notes, and snippets.

@theotherzach
Created September 19, 2012 15:29
Show Gist options
  • Save theotherzach/3750269 to your computer and use it in GitHub Desktop.
Save theotherzach/3750269 to your computer and use it in GitHub Desktop.
class Comment < ActiveRecord::Base
attr_accessible :subject, :body, :category, :reply_to
belongs_to :user
has_many :replies, :class_name => 'Comment',
:foreign_key => 'reply_to'
has_many :tags
scope :root, -> { where("reply_to = ?", 0 }
end
# Edited to rename Post to Comment
@mdarby
Copy link

mdarby commented Sep 19, 2012

We could do a placeholder, or just delete all sub comments as they would no longer make sense -- or we could not allow modifications of Comments once they've been commented on.

OR (yes, again), we could provide an option to do one of the three, and have it as an option settable by the Admin.

@theotherzach
Copy link
Author

I feel pretty OK about child posts going away after the parent is deleted. I can't think of any commenting system off the top of my head that does anything else with orphans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment