A place for my personal musings, about programming, design or whatever come across my mind

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 Comments
skim
skim

You should just be able to do:

Part.destroy_all

kahfei
kahfei

shorter and sweeter, thanks for the tips, skim

Leave A Comment