The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Threaded View

Deleting records with children

If I delete an object that has child objects, does rails automatically delete them as well or do I need to do it?

Say I have a model called Project and a model called Article. Project has_many articles and Article belongs_to a project. I can create a new article, but it only exists in the context of a project. Here is the destroy action from my ProjectController:

Should I add something in there that loops through all the child articles and deletes each one? If so, I'd guess that I would call a method in my model called something like kill_articles and pass it as an argument all the child articles. Any suggestions?