# Virtually deleting rows from tables

**URL:** <https://www.ruby-forum.com/t/virtually-deleting-rows-from-tables/125714>\
**Category:** Rails\
**Created:** [January 11, 2008, 12:12pm UTC](https://www.ruby-forum.com/t/virtually-deleting-rows-from-tables/125714 "2008-01-11T12:12:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pankaj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9adbd/32.png) [@pankaj](https://www.ruby-forum.com/u/pankaj)\
**Post date:** [January 11, 2008, 12:12pm UTC](https://www.ruby-forum.com/t/virtually-deleting-rows-from-tables/125714/1 "2008-01-11T12:12:15Z")

</div>

I dont want to delete the records from my tables but just set a column  
is\_deleted to true.  
What is the best (clean)way to implement this?

Is there any way of defining a model which includes only a set of  
records which satisfy a certain conditions.eg a condition to include  
the records for which is\_deleted is false  
some thing like this

def User \<\< ActiveRecord::Base  
:conditions=\> “is\_deleted=false”  
end  
Regards,  
Pankaj

---

<div class="post-metadata">

**Author:** ![pankaj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9adbd/32.png) [@pankaj](https://www.ruby-forum.com/u/pankaj)\
**Post date:** [January 11, 2008, 1:48pm UTC](https://www.ruby-forum.com/t/virtually-deleting-rows-from-tables/125714/2 "2008-01-11T13:48:28Z")

</div>

Hi,

You could override the destroy method in the controller:

UsersController\>\> ApplicationController  
…  
def destroy  
Car.find(params[:id]).is\_deleted = true  
redirect\_to :action =\> ‘list’  
end  
…  
end

Pablo.-

---

<div class="post-metadata">

**Author:** ![pankaj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9adbd/32.png) [@pankaj](https://www.ruby-forum.com/u/pankaj)\
**Post date:** [January 11, 2008, 3:46pm UTC](https://www.ruby-forum.com/t/virtually-deleting-rows-from-tables/125714/3 "2008-01-11T15:46:27Z")

</div>

the acts\_as\_paranoid plugin does this.
