Categories
ruby on rails

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

By kahfei

A system admin by day while secretly trying to transform myself to a coding designer or a designing coder at night.

2 replies on “destroy every record in a table in rails console”

Leave a Reply

Your email address will not be published. Required fields are marked *