This project is archived and is in readonly mode.

#849 ✓wontfix
Sergei

dependent => :delete_all

Reported by Sergei | August 17th, 2008 @ 06:39 PM | in 2.x

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

Comments and changes to this ticket

  • Ryan Bates

    Ryan Bates August 17th, 2008 @ 11:11 PM

    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.

  • josh

    josh November 22nd, 2008 @ 07:11 PM

    • State changed from “new” to “wontfix”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages