We're hiring. Join our team.

During development, you might find yourself needing to delete everything from a specific database table to refresh your data. You could drop the whole database and bring it back up again with rake:db:drop, rake:db:setup, but that’s slow and indiscriminate.

Instead, boot up a console and call delete_all on your model:

% rails c
> Advisory.count
# => 510 
> Advisory.delete_all
# => 510 
> Advisory.count
# => 0

I’ve been using this quite a bit while working on an idea related to security.dxw.com – more on that soon.

2 comments

  1. Comment by M Rafiq posted

    not working delete_all command, showing the count but not deleting the record.

  2. Comment by M Rafiq posted

    not working delete_all command, showing the count but not deleting the record.

Comments are closed.