How to override ActiveRecord#base#destroy

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs