deleting a forum topic should delete its posts

This commit is contained in:
albert
2011-01-12 18:06:46 -05:00
parent 668fbab77a
commit d6f1d09da0
3 changed files with 24 additions and 1 deletions

View File

@@ -2,7 +2,7 @@ class ForumTopic < ActiveRecord::Base
attr_accessible :title, :original_post_attributes
belongs_to :creator, :class_name => "User"
belongs_to :updater, :class_name => "User"
has_many :posts, :class_name => "ForumPost", :order => "forum_posts.id asc", :foreign_key => "topic_id"
has_many :posts, :class_name => "ForumPost", :order => "forum_posts.id asc", :foreign_key => "topic_id", :dependent => :destroy
has_one :original_post, :class_name => "ForumPost", :order => "forum_posts.id asc", :foreign_key => "topic_id"
before_validation :initialize_creator, :on => :create
before_validation :initialize_updater