Destroy Children In Rails 2.3

In the parent class place the following code

has_many :posts, :dependent => :destroy

This used to be accomplished with

has_many :posts, :dependent=>true

Check out the Rails docs for more information http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

Related posts:

  1. Rake DB Everything, Dump, Destroy, Create, Load
  2. Validate Uniqueness on Join Tables in Rails
  3. Email Obfuscation and Extraction from Text with Rails
  4. named_scope in Rails
  5. Date and Time Helpers in Rails
This entry was posted in Ruby on Rails and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>