# Parent Child Relationship

**URL:** <https://www.ruby-forum.com/t/parent-child-relationship/114623>\
**Category:** Rails\
**Created:** [September 17, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/parent-child-relationship/114623 "2007-09-17T13:23:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bparanj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9a140/32.png) [@bparanj](https://www.ruby-forum.com/u/bparanj)\
**Post date:** [September 17, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/parent-child-relationship/114623/1 "2007-09-17T13:23:08Z")

</div>

class Event \< ActiveRecord::Base  
has\_many :categories  
end

If I delete a category, it affects the events that were created  
before. How can make sure that event can still display it’s old  
category name? TIA.

---

<div class="post-metadata">

**Author:** ![bparanj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e9a140/32.png) [@bparanj](https://www.ruby-forum.com/u/bparanj)\
**Post date:** [September 17, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/parent-child-relationship/114623/2 "2007-09-17T13:23:11Z")

</div>

Look at acts\_as\_paranoid. I use it for a similar, but different reason,  
but it may help you. Basically, if you add acts\_as\_paranoid to your  
category model, when you destroy a category, it actually sets a column  
deleted\_at to the current time. Acts\_as\_paranoid overrides the find and  
count methods to ignore anything that has deleted\_at not null. However,  
it has accessor methods that allow you to return all categories  
including those with the deleted\_at column set. I heard someone say that  
the author of this plugin may not be supporting it in the future,  
however, I am using it with no issues. YMMV

[http://wiki.rubyonrails.org/rails/pages/Acts+As+Paranoid+Plugin](http://wiki.rubyonrails.org/rails/pages/Acts+As+Paranoid+Plugin)
