Browse files

Adds dependent destroy on user/post/comment models

  • Loading branch information...
1 parent eca0cf9 commit ce826326cbebb9ee2fae337b8d38bd2f81c82123 Javier Fonseca V committed Nov 21, 2012
Showing with 2 additions and 2 deletions.
  1. +1 −1 app/models/post.rb
  2. +1 −1 app/models/user.rb
View
2 app/models/post.rb
@@ -1,6 +1,6 @@
class Post < ActiveRecord::Base
belongs_to :user
- has_many :comments
+ has_many :comments, :dependent => :destroy
validates_presence_of :title, :content, :user_id
attr_accessible :title, :content
View
2 app/models/user.rb
@@ -1,5 +1,5 @@
class User < ActiveRecord::Base
- has_many :posts
+ has_many :posts, :dependent => :destroy
validates_presence_of :full_name

0 comments on commit ce82632

Please sign in to comment.