# How to override ActiveRecord#base#destroy

**URL:** <https://www.ruby-forum.com/t/how-to-override-activerecord-base-destroy/97053>\
**Category:** Rails\
**Created:** [July 4, 2006, 3:57pm UTC](https://www.ruby-forum.com/t/how-to-override-activerecord-base-destroy/97053 "2006-07-04T15:57:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![torsten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8e8cbc/32.png) [@torsten](https://www.ruby-forum.com/u/torsten)\
**Post date:** [July 4, 2006, 3:57pm UTC](https://www.ruby-forum.com/t/how-to-override-activerecord-base-destroy/97053/1 "2006-07-04T15:57:54Z")

</div>

Hello,  
I have a database table with a primary key not being a simple id but  
three columns. By overriding update() and create() I got Rails to work  
with that table quit good. Except for the destroy() action. From the  
resulting trace I can see that the old version of destroy() is called  
from transaction.rb. I think this lines might be the reason that I’m  
unable to override detroy():

from transaction.rb

```
 def self.append_features(base)
   super
   base.extend(ClassMethods)

   base.class_eval do
     alias_method :destroy_without_transactions, :destroy
     alias_method :destroy, :destroy_with_transactions

```

…

Any ideas, hints, etc.?

best regards,  
Torsten

---

<div class="post-metadata">

**Author:** ![torsten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8e8cbc/32.png) [@torsten](https://www.ruby-forum.com/u/torsten)\
**Post date:** [July 5, 2006, 12:32pm UTC](https://www.ruby-forum.com/t/how-to-override-activerecord-base-destroy/97053/2 "2006-07-05T12:32:42Z")

</div>

Torsten R. wrote:

> Hello,  
> I have a database table with a primary key not being a simple id but  
> three columns. By overriding update() and create() I got Rails to work  
> with that table quit good. Except for the destroy() action. From the  
> resulting trace I can see that the old version of destroy() is called  
> from transaction.rb. I think this lines might be the reason that I’m  
> unable to override detroy():

Add on: My fault, I simply picked the wrong model class. Now with  
overloading update(), create() and destroy() in the right model class  
with natural primary keys every thing works as expected.

best regards  
Torsten
