Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

dependent => :delete_all

#849

By mistake, when describing a model I said "dependent => delete_all" without the leading colon before "delete_all". Rails complained and I put the colon in. The surprise came when I saw that all development data from the table that the model described were gone.

Now, I understand that delete_all in the context of a rails class describing a model will indeed delete everything but somehow I didn't expect that side effect while describing a "has_many" association :)

Maybe this report could be useful.

Thanks, Sergei

Reported by Sergei · August 17th, 2008 @ 06:39 PM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Ryan Bates
    Ryan Bates

    In Ruby, a method called at the class level is called directly on the class.

    
    Item.delete_all
    
    # is the same as
    
    class Item
      delete_all
    end
    

    I do see how it's an easy mistake to make, but I don't think there's an easy solution to this since it's how Ruby behaves.

    August 17th, 2008 @ 11:11 PM

  2. josh
    josh
    • State changed from new to wontfix

    November 22nd, 2008 @ 07:11 PM