Skip to content

Instantly share code, notes, and snippets.

@theotherzach
Created September 19, 2012 15:29
Show Gist options
  • Select an option

  • Save theotherzach/3750269 to your computer and use it in GitHub Desktop.

Select an option

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
@theotherzach
Copy link
Copy Markdown
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