destroy every record in a table in rails console

This is really useful, as I keep googling it everytime I wanna do this with the rails console…

Part.find(:all).each{|p|p.destroy}

Got it from the comment section from this post

A much shorter way of doing so, as comment by skim,

Part.destroy_all

2 Responses to “destroy every record in a table in rails console”

  1. skim says:

    You should just be able to do:

    Part.destroy_all

  2. kahfei says:

    shorter and sweeter, thanks for the tips, skim

Leave a Reply