# How can I drop all table data in one hit, from within ruby code (controller or model)?

**URL:** <https://www.ruby-forum.com/t/how-can-i-drop-all-table-data-in-one-hit-from-within-ruby-code-controller-or-model/141042>\
**Category:** Rails\
**Created:** [June 21, 2008, 6:34am UTC](https://www.ruby-forum.com/t/how-can-i-drop-all-table-data-in-one-hit-from-within-ruby-code-controller-or-model/141042 "2008-06-21T06:34:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [June 21, 2008, 6:34am UTC](https://www.ruby-forum.com/t/how-can-i-drop-all-table-data-in-one-hit-from-within-ruby-code-controller-or-model/141042/1 "2008-06-21T06:34:09Z")

</div>

how can I drop all table data in one hit, from within ruby code  
(controller  
or model)? (i.e. prior to updating my projections table I need to delete  
all  
existing data first)

thanks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [June 21, 2008, 6:38am UTC](https://www.ruby-forum.com/t/how-can-i-drop-all-table-data-in-one-hit-from-within-ruby-code-controller-or-model/141042/2 "2008-06-21T06:38:15Z")

</div>

Are you looking for this:  
[http://railsapi.org/activerecord-base-delete\_all](http://railsapi.org/activerecord-base-delete_all)

Basically, delete\_all should do what you’re asking.

HTH

On Jun 21, 12:33 am, “Greg H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
